Mercurial > emacs
annotate lisp/progmodes/cc-defs.el @ 100679:22cd960b6c0e
Add bug id for recently fixed bugs.
author | Jason Rumney <jasonr@gnu.org> |
---|---|
date | Thu, 25 Dec 2008 01:15:03 +0000 |
parents | 08780e762816 |
children | a9dc0e7c3f2b |
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 |
74372 | 3 ;; Copyright (C) 1985, 1987, 1992, 1993, 1994, 1995, 1996, 1997, 1998, |
79717 | 4 ;; 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 |
75347 | 5 ;; Free Software Foundation, Inc. |
18720 | 6 |
75307 | 7 ;; Authors: 2003- Alan Mackenzie |
8 ;; 1998- Martin Stjernholm | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
9 ;; 1992-1999 Barry A. Warsaw |
18720 | 10 ;; 1987 Dave Detlefs and Stewart Clamen |
11 ;; 1985 Richard M. Stallman | |
24282 | 12 ;; Maintainer: bug-cc-mode@gnu.org |
18720 | 13 ;; Created: 22-Apr-1997 (split from cc-mode.el) |
20141 | 14 ;; Version: See cc-mode.el |
18720 | 15 ;; Keywords: c languages oop |
16 | |
17 ;; This file is part of GNU Emacs. | |
18 | |
94673
52b7a8c22af5
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
19 ;; GNU Emacs is free software: you can redistribute it and/or modify |
18720 | 20 ;; it under the terms of the GNU General Public License as published by |
94673
52b7a8c22af5
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
21 ;; the Free Software Foundation, either version 3 of the License, or |
52b7a8c22af5
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
22 ;; (at your option) any later version. |
18720 | 23 |
24 ;; GNU Emacs is distributed in the hope that it will be useful, | |
25 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
26 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
27 ;; GNU General Public License for more details. | |
28 | |
29 ;; You should have received a copy of the GNU General Public License | |
94673
52b7a8c22af5
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
30 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
18720 | 31 |
38422
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
36920
diff
changeset
|
32 ;;; Commentary: |
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
36920
diff
changeset
|
33 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
34 ;; 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
|
35 ;; 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
|
36 |
38422
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
36920
diff
changeset
|
37 ;;; Code: |
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
36920
diff
changeset
|
38 |
36920 | 39 (eval-when-compile |
40 (let ((load-path | |
41 (if (and (boundp 'byte-compile-dest-file) | |
42 (stringp byte-compile-dest-file)) | |
43 (cons (file-name-directory byte-compile-dest-file) load-path) | |
44 load-path))) | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
45 (load "cc-bytecomp" nil t))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
46 |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
47 (eval-when-compile (require 'cl)) ; was (cc-external-require 'cl). ACM 2005/11/29. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
48 (cc-external-require 'regexp-opt) |
24282 | 49 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
50 ;; Silence the compiler. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
51 (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
|
52 (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
|
53 (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
|
54 (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
|
55 (cc-bytecomp-defvar zmacs-regions) ; XEmacs |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
56 (cc-bytecomp-defvar mark-active) ; Emacs |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
57 (cc-bytecomp-defvar deactivate-mark) ; Emacs |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
58 (cc-bytecomp-defvar inhibit-point-motion-hooks) ; Emacs |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
59 (cc-bytecomp-defvar parse-sexp-lookup-properties) ; Emacs |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
60 (cc-bytecomp-defvar text-property-default-nonsticky) ; Emacs 21 |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
61 (cc-bytecomp-defvar lookup-syntax-properties) ; XEmacs |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
62 (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
|
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 | |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
68 (if (or (/= (regexp-opt-depth "\\(\\(\\)\\)") 2) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
69 (not (fboundp 'push))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
70 (cc-load "cc-fix"))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
71 |
71754
60304f6ae360
* progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents:
69140
diff
changeset
|
72 ; (eval-after-load "font-lock" ; 2006-07-09. font-lock is now preloaded |
60304f6ae360
* progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents:
69140
diff
changeset
|
73 ; ' |
85703
49b7304c73bb
Reorder conditions to avoid warnings.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78234
diff
changeset
|
74 (if (and (featurep 'xemacs) ; There is now (2005/12) code in GNU Emacs CVS |
77081
e8bd3e011b64
Changes to make `narrow-to-defun' and `mark-defun' work properly in CC
Alan Mackenzie <acm@muc.de>
parents:
75515
diff
changeset
|
75 ; to make the call to f-l-c-k throw an error. |
85703
49b7304c73bb
Reorder conditions to avoid warnings.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78234
diff
changeset
|
76 (not (featurep 'cc-fix)) ; only load the file once. |
77081
e8bd3e011b64
Changes to make `narrow-to-defun' and `mark-defun' work properly in CC
Alan Mackenzie <acm@muc.de>
parents:
75515
diff
changeset
|
77 (let (font-lock-keywords) |
e8bd3e011b64
Changes to make `narrow-to-defun' and `mark-defun' work properly in CC
Alan Mackenzie <acm@muc.de>
parents:
75515
diff
changeset
|
78 (font-lock-compile-keywords '("\\<\\>")) |
e8bd3e011b64
Changes to make `narrow-to-defun' and `mark-defun' work properly in CC
Alan Mackenzie <acm@muc.de>
parents:
75515
diff
changeset
|
79 font-lock-keywords)) ; did the previous call foul this up? |
e8bd3e011b64
Changes to make `narrow-to-defun' and `mark-defun' work properly in CC
Alan Mackenzie <acm@muc.de>
parents:
75515
diff
changeset
|
80 (load "cc-fix")) ;) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
81 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
82 ;; 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
|
83 ;; to ensure correct byte compilation. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
84 (eval-when-compile |
85703
49b7304c73bb
Reorder conditions to avoid warnings.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78234
diff
changeset
|
85 (if (and (featurep 'xemacs) |
49b7304c73bb
Reorder conditions to avoid warnings.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78234
diff
changeset
|
86 (not (featurep 'cc-fix)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
87 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
88 (require 'font-lock) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
89 (let (font-lock-keywords) |
69140
3d8b060d10fb
cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents:
68773
diff
changeset
|
90 (font-lock-compile-keywords '("\\<\\>")) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
91 font-lock-keywords))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
92 (cc-load "cc-fix"))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
93 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
94 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
95 ;;; Variables also used at compile time. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
96 |
97971
620d3d9a95da
(c-version): Increment to 5.31.6.
Alan Mackenzie <acm@muc.de>
parents:
97441
diff
changeset
|
97 (defconst c-version "5.31.6" |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
98 "CC Mode version number.") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
99 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
100 (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
|
101 ;; 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
|
102 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
103 (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
|
104 "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
|
105 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
|
106 `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
|
107 `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
|
108 `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
|
109 \(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
|
110 not known.") |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
111 (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
|
112 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
113 ;; 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
|
114 ;; 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
|
115 (put 'c-buffer-is-cc-mode 'permanent-local t) |
36920 | 116 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
117 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
118 ;; 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
|
119 (eval-and-compile |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
120 (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
|
121 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
122 (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
|
123 "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
|
124 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
|
125 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
126 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
|
127 \(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
|
128 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
129 (if c-inside-eval-when-compile |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
130 ;; 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
|
131 ;; 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
|
132 ;; 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
|
133 ;; bound variable to avoid nesting them. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
134 `(progn ,@body) |
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 `(eval-when-compile |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
137 ;; 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
|
138 ;; 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
|
139 ;; 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
|
140 ;; compiled. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
141 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
142 ;; 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
|
143 ;; 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
|
144 ;; `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
|
145 ;; 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
|
146 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
147 ;; (defsubst nthcdr (val) val) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
148 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
149 ;; `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
|
150 ;; 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
|
151 ;; compilation. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
152 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
153 ;; 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
|
154 ;; 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
|
155 ;; to conditionally do a `defsubst': |
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 ;; (eval-when-compile |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
158 ;; (if (not (fboundp 'foo)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
159 ;; (defsubst foo ...))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
160 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
161 ;; 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
|
162 ;; _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
|
163 ;; 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
|
164 ;; 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
|
165 ;; 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
|
166 ;; 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
|
167 ;; 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
|
168 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
169 ;; 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
|
170 ;; 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
|
171 ;; 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
|
172 ;; compiled (even if `function' is used). |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
173 (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
|
174 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
175 (put 'cc-eval-when-compile 'lisp-indent-hook 0)) |
24282 | 176 |
177 | |
36920 | 178 ;;; Macros. |
179 | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
180 (defmacro c-point (position &optional point) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
181 "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
|
182 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
|
183 one of the following symbols: |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
184 |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
185 `bol' -- beginning of line |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
186 `eol' -- end of line |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
187 `bod' -- beginning of defun |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
188 `eod' -- end of defun |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
189 `boi' -- beginning of indentation |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
190 `ionl' -- indentation of next line |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
191 `iopl' -- indentation of previous line |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
192 `bonl' -- beginning of next line |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
193 `eonl' -- end of next line |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
194 `bopl' -- beginning of previous line |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
195 `eopl' -- end of previous line |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
196 `bosws' -- beginning of syntactic whitespace |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
197 `eosws' -- end of syntactic whitespace |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
198 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
199 If the referenced position doesn't exist, the closest accessible point |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
200 to it is returned. This function does not modify the point or the mark." |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
201 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
202 (if (eq (car-safe position) 'quote) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
203 (let ((position (eval position))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
204 (cond |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
205 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
206 ((eq position 'bol) |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
207 (if (and (cc-bytecomp-fboundp 'line-beginning-position) (not point)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
208 `(line-beginning-position) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
209 `(save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
210 ,@(if point `((goto-char ,point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
211 (beginning-of-line) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
212 (point)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
213 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
214 ((eq position 'eol) |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
215 (if (and (cc-bytecomp-fboundp 'line-end-position) (not point)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
216 `(line-end-position) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
217 `(save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
218 ,@(if point `((goto-char ,point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
219 (end-of-line) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
220 (point)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
221 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
222 ((eq position 'boi) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
223 `(save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
224 ,@(if point `((goto-char ,point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
225 (back-to-indentation) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
226 (point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
227 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
228 ((eq position 'bod) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
229 `(save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
230 ,@(if point `((goto-char ,point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
231 (c-beginning-of-defun-1) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
232 (point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
233 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
234 ((eq position 'eod) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
235 `(save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
236 ,@(if point `((goto-char ,point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
237 (c-end-of-defun-1) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
238 (point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
239 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
240 ((eq position 'bopl) |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
241 (if (and (cc-bytecomp-fboundp 'line-beginning-position) (not point)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
242 `(line-beginning-position 0) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
243 `(save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
244 ,@(if point `((goto-char ,point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
245 (forward-line -1) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
246 (point)))) |
36920 | 247 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
248 ((eq position 'bonl) |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
249 (if (and (cc-bytecomp-fboundp 'line-beginning-position) (not point)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
250 `(line-beginning-position 2) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
251 `(save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
252 ,@(if point `((goto-char ,point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
253 (forward-line 1) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
254 (point)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
255 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
256 ((eq position 'eopl) |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
257 (if (and (cc-bytecomp-fboundp 'line-end-position) (not point)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
258 `(line-end-position 0) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
259 `(save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
260 ,@(if point `((goto-char ,point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
261 (beginning-of-line) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
262 (or (bobp) (backward-char)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
263 (point)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
264 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
265 ((eq position 'eonl) |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
266 (if (and (cc-bytecomp-fboundp 'line-end-position) (not point)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
267 `(line-end-position 2) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
268 `(save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
269 ,@(if point `((goto-char ,point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
270 (forward-line 1) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
271 (end-of-line) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
272 (point)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
273 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
274 ((eq position 'iopl) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
275 `(save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
276 ,@(if point `((goto-char ,point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
277 (forward-line -1) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
278 (back-to-indentation) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
279 (point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
280 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
281 ((eq position 'ionl) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
282 `(save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
283 ,@(if point `((goto-char ,point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
284 (forward-line 1) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
285 (back-to-indentation) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
286 (point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
287 |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
288 ((eq position 'bosws) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
289 `(save-excursion |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
290 ,@(if point `((goto-char ,point))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
291 (c-backward-syntactic-ws) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
292 (point))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
293 |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
294 ((eq position 'eosws) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
295 `(save-excursion |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
296 ,@(if point `((goto-char ,point))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
297 (c-forward-syntactic-ws) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
298 (point))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
299 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
300 (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
|
301 |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
302 ;; The bulk of this should perhaps be in a function to avoid large |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
303 ;; expansions, but this case is not used anywhere in CC Mode (and |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
304 ;; probably not anywhere else either) so we only have it to be on |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
305 ;; the safe side. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
306 (message "Warning: c-point long expansion") |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
307 `(save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
308 ,@(if point `((goto-char ,point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
309 (let ((position ,position)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
310 (cond |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
311 ((eq position 'bol) (beginning-of-line)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
312 ((eq position 'eol) (end-of-line)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
313 ((eq position 'boi) (back-to-indentation)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
314 ((eq position 'bod) (c-beginning-of-defun-1)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
315 ((eq position 'eod) (c-end-of-defun-1)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
316 ((eq position 'bopl) (forward-line -1)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
317 ((eq position 'bonl) (forward-line 1)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
318 ((eq position 'eopl) (progn |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
319 (beginning-of-line) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
320 (or (bobp) (backward-char)))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
321 ((eq position 'eonl) (progn |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
322 (forward-line 1) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
323 (end-of-line))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
324 ((eq position 'iopl) (progn |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
325 (forward-line -1) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
326 (back-to-indentation))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
327 ((eq position 'ionl) (progn |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
328 (forward-line 1) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
329 (back-to-indentation))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
330 ((eq position 'bosws) (c-backward-syntactic-ws)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
331 ((eq position 'eosws) (c-forward-syntactic-ws)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
332 (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
|
333 (point)))) |
18720 | 334 |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
335 (defmacro c-region-is-active-p () |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
336 ;; Return t when the region is active. The determination of region |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
337 ;; activeness is different in both Emacs and XEmacs. |
87397
6bf362c56364
(c-region-is-active-p): Use `mark-active' if it's defined.
Richard M. Stallman <rms@gnu.org>
parents:
85703
diff
changeset
|
338 (if (cc-bytecomp-boundp 'mark-active) |
6bf362c56364
(c-region-is-active-p): Use `mark-active' if it's defined.
Richard M. Stallman <rms@gnu.org>
parents:
85703
diff
changeset
|
339 ;; Emacs. |
6bf362c56364
(c-region-is-active-p): Use `mark-active' if it's defined.
Richard M. Stallman <rms@gnu.org>
parents:
85703
diff
changeset
|
340 'mark-active |
6bf362c56364
(c-region-is-active-p): Use `mark-active' if it's defined.
Richard M. Stallman <rms@gnu.org>
parents:
85703
diff
changeset
|
341 ;; XEmacs. |
6bf362c56364
(c-region-is-active-p): Use `mark-active' if it's defined.
Richard M. Stallman <rms@gnu.org>
parents:
85703
diff
changeset
|
342 '(region-active-p))) |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
343 |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
344 (defmacro c-set-region-active (activate) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
345 ;; Activate the region if ACTIVE is non-nil, deactivate it |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
346 ;; otherwise. Covers the differences between Emacs and XEmacs. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
347 (if (cc-bytecomp-fboundp 'zmacs-activate-region) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
348 ;; XEmacs. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
349 `(if ,activate |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
350 (zmacs-activate-region) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
351 (zmacs-deactivate-region)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
352 ;; Emacs. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
353 `(setq mark-active ,activate))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
354 |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
355 (defmacro c-delete-and-extract-region (start end) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
356 "Delete the text between START and END and return it." |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
357 (if (cc-bytecomp-fboundp 'delete-and-extract-region) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
358 ;; Emacs 21.1 and later |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
359 `(delete-and-extract-region ,start ,end) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
360 ;; XEmacs and Emacs 20.x |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
361 `(prog1 |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
362 (buffer-substring ,start ,end) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
363 (delete-region ,start ,end)))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
364 |
18720 | 365 (defmacro c-safe (&rest body) |
366 ;; safely execute BODY, return nil if an error occurred | |
26817 | 367 `(condition-case nil |
368 (progn ,@body) | |
369 (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
|
370 (put 'c-safe 'lisp-indent-function 0) |
26817 | 371 |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
372 (defmacro c-int-to-char (integer) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
373 ;; In GNU Emacs, a character is an integer. In XEmacs, a character is a |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
374 ;; type distinct from an integer. Sometimes we need to convert integers to |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
375 ;; characters. `c-int-to-char' makes this conversion, if necessary. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
376 (if (fboundp 'int-to-char) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
377 `(int-to-char ,integer) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
378 integer)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
379 |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
380 (defmacro c-sentence-end () |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
381 ;; Get the regular expression `sentence-end'. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
382 (if (cc-bytecomp-fboundp 'sentence-end) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
383 ;; Emacs 22: |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
384 `(sentence-end) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
385 ;; Emacs <22 + XEmacs |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
386 `sentence-end)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
387 |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
388 (defmacro c-default-value-sentence-end () |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
389 ;; Get the default value of the variable sentence end. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
390 (if (cc-bytecomp-fboundp 'sentence-end) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
391 ;; Emacs 22: |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
392 `(let (sentence-end) (sentence-end)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
393 ;; Emacs <22 + XEmacs |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
394 `(default-value 'sentence-end))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
395 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
396 ;; 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
|
397 ;; 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
|
398 (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
|
399 "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
|
400 then restore the buffer state under the assumption that no significant |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
401 modification has been made in BODY. A change is considered |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
402 significant if it affects the buffer text in any way that isn't |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
403 completely restored again. Changes in text properties like `face' or |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
404 `syntax-table' are considered insignificant. This macro allows text |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
405 properties to be changed, even in a read-only buffer. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
406 |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
407 This macro should be placed around all calculations which set |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
408 \"insignificant\" text properties in a buffer, even when the buffer is |
100148 | 409 known to be writable. That way, these text properties remain set |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
410 even if the user undoes the command which set them. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
411 |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
412 This macro should ALWAYS be placed around \"temporary\" internal buffer |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
413 changes \(like adding a newline to calculate a text-property then |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
414 deleting it again\), so that the user never sees them on his |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
415 `buffer-undo-list'. See also `c-tentative-buffer-changes'. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
416 |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
417 However, any user-visible changes to the buffer \(like auto-newlines\) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
418 must not be within a `c-save-buffer-state', since the user then |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
419 wouldn't be able to undo them. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
420 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
421 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
|
422 `(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
|
423 (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
|
424 before-change-functions after-change-functions |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
425 deactivate-mark |
79934
225355012caa
(c-save-buffer-state): Bind buffer-file-name and buffer-file-truename to
Alan Mackenzie <acm@muc.de>
parents:
79717
diff
changeset
|
426 buffer-file-name buffer-file-truename ; Prevent primitives checking |
225355012caa
(c-save-buffer-state): Bind buffer-file-name and buffer-file-truename to
Alan Mackenzie <acm@muc.de>
parents:
79717
diff
changeset
|
427 ; for file modification |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
428 ,@varlist) |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
429 (unwind-protect |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
430 (progn ,@body) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
431 (and (not modified) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
432 (buffer-modified-p) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
433 (set-buffer-modified-p nil))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
434 (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
|
435 |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
436 (defmacro c-tentative-buffer-changes (&rest body) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
437 "Eval BODY and optionally restore the buffer contents to the state it |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
438 was in before BODY. Any changes are kept if the last form in BODY |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
439 returns non-nil. Otherwise it's undone using the undo facility, and |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
440 various other buffer state that might be affected by the changes is |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
441 restored. That includes the current buffer, point, mark, mark |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
442 activation \(similar to `save-excursion'), and the modified state. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
443 The state is also restored if BODY exits nonlocally. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
444 |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
445 If BODY makes a change that unconditionally is undone then wrap this |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
446 macro inside `c-save-buffer-state'. That way the change can be done |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
447 even when the buffer is read-only, and without interference from |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
448 various buffer change hooks." |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
449 `(let (-tnt-chng-keep |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
450 -tnt-chng-state) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
451 (unwind-protect |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
452 ;; Insert an undo boundary for use with `undo-more'. We |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
453 ;; don't use `undo-boundary' since it doesn't insert one |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
454 ;; unconditionally. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
455 (setq buffer-undo-list (cons nil buffer-undo-list) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
456 -tnt-chng-state (c-tnt-chng-record-state) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
457 -tnt-chng-keep (progn ,@body)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
458 (c-tnt-chng-cleanup -tnt-chng-keep -tnt-chng-state)))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
459 (put 'c-tentative-buffer-changes 'lisp-indent-function 0) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
460 |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
461 (defun c-tnt-chng-record-state () |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
462 ;; Used internally in `c-tentative-buffer-changes'. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
463 (vector buffer-undo-list ; 0 |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
464 (current-buffer) ; 1 |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
465 ;; No need to use markers for the point and mark; if the |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
466 ;; undo got out of synch we're hosed anyway. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
467 (point) ; 2 |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
468 (mark t) ; 3 |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
469 (c-region-is-active-p) ; 4 |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
470 (buffer-modified-p))) ; 5 |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
471 |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
472 (defun c-tnt-chng-cleanup (keep saved-state) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
473 ;; Used internally in `c-tentative-buffer-changes'. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
474 |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
475 (let ((saved-undo-list (elt saved-state 0))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
476 (if (eq buffer-undo-list saved-undo-list) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
477 ;; No change was done afterall. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
478 (setq buffer-undo-list (cdr saved-undo-list)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
479 |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
480 (if keep |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
481 ;; Find and remove the undo boundary. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
482 (let ((p buffer-undo-list)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
483 (while (not (eq (cdr p) saved-undo-list)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
484 (setq p (cdr p))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
485 (setcdr p (cdr saved-undo-list))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
486 |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
487 ;; `primitive-undo' will remove the boundary. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
488 (setq saved-undo-list (cdr saved-undo-list)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
489 (let ((undo-in-progress t)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
490 (while (not (eq (setq buffer-undo-list |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
491 (primitive-undo 1 buffer-undo-list)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
492 saved-undo-list)))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
493 |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
494 (when (buffer-live-p (elt saved-state 1)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
495 (set-buffer (elt saved-state 1)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
496 (goto-char (elt saved-state 2)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
497 (set-mark (elt saved-state 3)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
498 (c-set-region-active (elt saved-state 4)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
499 (and (not (elt saved-state 5)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
500 (buffer-modified-p) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
501 (set-buffer-modified-p nil))))))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
502 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
503 (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
|
504 "Forward skip over syntactic whitespace. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
505 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
|
506 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
|
507 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
|
508 whitespace. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
509 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
510 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
|
511 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
|
512 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
|
513 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
514 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
|
515 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
|
516 (if limit |
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 (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
|
519 (c-forward-sws)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
520 '(c-forward-sws))) |
36920 | 521 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
522 (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
|
523 "Backward skip over syntactic whitespace. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
524 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
|
525 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
|
526 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
|
527 whitespace. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
528 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
529 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
|
530 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
|
531 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
|
532 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
533 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
|
534 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
|
535 (if limit |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
536 `(save-restriction |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
537 (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
|
538 (c-backward-sws)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
539 '(c-backward-sws))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
540 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
541 (defmacro c-forward-sexp (&optional count) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
542 "Move forward across COUNT balanced expressions. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
543 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
|
544 fails for any reason. |
36920 | 545 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
546 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
|
547 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
|
548 susceptible to user configurations such as disabling of signals in |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
549 certain situations." |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
550 (or count (setq count 1)) |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
551 `(goto-char (scan-sexps (point) ,count))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
552 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
553 (defmacro c-backward-sexp (&optional count) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
554 "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
|
555 (or count (setq count 1)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
556 `(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
|
557 |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
558 (defmacro c-safe-scan-lists (from count depth &optional limit) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
559 "Like `scan-lists' but returns nil instead of signalling errors |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
560 for unbalanced parens. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
561 |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
562 A limit for the search may be given. FROM is assumed to be on the |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
563 right side of it." |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
564 (let ((res (if (featurep 'xemacs) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
565 `(scan-lists ,from ,count ,depth nil t) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
566 `(c-safe (scan-lists ,from ,count ,depth))))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
567 (if limit |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
568 `(save-restriction |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
569 ,(if (numberp count) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
570 (if (< count 0) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
571 `(narrow-to-region ,limit (point-max)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
572 `(narrow-to-region (point-min) ,limit)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
573 `(if (< ,count 0) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
574 (narrow-to-region ,limit (point-max)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
575 (narrow-to-region (point-min) ,limit))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
576 ,res) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
577 res))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
578 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
579 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
580 ;; 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
|
581 ;; 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
|
582 |
75313
bbe81c239799
Add new functions, c-go-list-forward, c-go-list-backward.
Alan Mackenzie <acm@muc.de>
parents:
75307
diff
changeset
|
583 (defmacro c-go-list-forward () |
bbe81c239799
Add new functions, c-go-list-forward, c-go-list-backward.
Alan Mackenzie <acm@muc.de>
parents:
75307
diff
changeset
|
584 "Move backward across one balanced group of parentheses. |
bbe81c239799
Add new functions, c-go-list-forward, c-go-list-backward.
Alan Mackenzie <acm@muc.de>
parents:
75307
diff
changeset
|
585 |
bbe81c239799
Add new functions, c-go-list-forward, c-go-list-backward.
Alan Mackenzie <acm@muc.de>
parents:
75307
diff
changeset
|
586 Return POINT when we succeed, NIL when we fail. In the latter case, leave |
bbe81c239799
Add new functions, c-go-list-forward, c-go-list-backward.
Alan Mackenzie <acm@muc.de>
parents:
75307
diff
changeset
|
587 point unmoved." |
bbe81c239799
Add new functions, c-go-list-forward, c-go-list-backward.
Alan Mackenzie <acm@muc.de>
parents:
75307
diff
changeset
|
588 `(c-safe (let ((endpos (scan-lists (point) 1 0))) |
bbe81c239799
Add new functions, c-go-list-forward, c-go-list-backward.
Alan Mackenzie <acm@muc.de>
parents:
75307
diff
changeset
|
589 (goto-char endpos) |
bbe81c239799
Add new functions, c-go-list-forward, c-go-list-backward.
Alan Mackenzie <acm@muc.de>
parents:
75307
diff
changeset
|
590 endpos))) |
bbe81c239799
Add new functions, c-go-list-forward, c-go-list-backward.
Alan Mackenzie <acm@muc.de>
parents:
75307
diff
changeset
|
591 |
bbe81c239799
Add new functions, c-go-list-forward, c-go-list-backward.
Alan Mackenzie <acm@muc.de>
parents:
75307
diff
changeset
|
592 (defmacro c-go-list-backward () |
bbe81c239799
Add new functions, c-go-list-forward, c-go-list-backward.
Alan Mackenzie <acm@muc.de>
parents:
75307
diff
changeset
|
593 "Move backward across one balanced group of parentheses. |
bbe81c239799
Add new functions, c-go-list-forward, c-go-list-backward.
Alan Mackenzie <acm@muc.de>
parents:
75307
diff
changeset
|
594 |
bbe81c239799
Add new functions, c-go-list-forward, c-go-list-backward.
Alan Mackenzie <acm@muc.de>
parents:
75307
diff
changeset
|
595 Return POINT when we succeed, NIL when we fail. In the latter case, leave |
bbe81c239799
Add new functions, c-go-list-forward, c-go-list-backward.
Alan Mackenzie <acm@muc.de>
parents:
75307
diff
changeset
|
596 point unmoved." |
bbe81c239799
Add new functions, c-go-list-forward, c-go-list-backward.
Alan Mackenzie <acm@muc.de>
parents:
75307
diff
changeset
|
597 `(c-safe (let ((endpos (scan-lists (point) -1 0))) |
bbe81c239799
Add new functions, c-go-list-forward, c-go-list-backward.
Alan Mackenzie <acm@muc.de>
parents:
75307
diff
changeset
|
598 (goto-char endpos) |
bbe81c239799
Add new functions, c-go-list-forward, c-go-list-backward.
Alan Mackenzie <acm@muc.de>
parents:
75307
diff
changeset
|
599 endpos))) |
bbe81c239799
Add new functions, c-go-list-forward, c-go-list-backward.
Alan Mackenzie <acm@muc.de>
parents:
75307
diff
changeset
|
600 |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
601 (defmacro c-up-list-forward (&optional pos limit) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
602 "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
|
603 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
|
604 |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
605 A limit for the search may be given. The start position is assumed to |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
606 be before it." |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
607 `(c-safe-scan-lists ,(or pos `(point)) 1 1 ,limit)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
608 |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
609 (defmacro c-up-list-backward (&optional pos limit) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
610 "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
|
611 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
|
612 |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
613 A limit for the search may be given. The start position is assumed to |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
614 be after it." |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
615 `(c-safe-scan-lists ,(or pos `(point)) -1 1 ,limit)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
616 |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
617 (defmacro c-down-list-forward (&optional pos limit) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
618 "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
|
619 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
|
620 |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
621 A limit for the search may be given. The start position is assumed to |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
622 be before it." |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
623 `(c-safe-scan-lists ,(or pos `(point)) 1 -1 ,limit)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
624 |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
625 (defmacro c-down-list-backward (&optional pos limit) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
626 "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
|
627 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
|
628 |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
629 A limit for the search may be given. The start position is assumed to |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
630 be after it." |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
631 `(c-safe-scan-lists ,(or pos `(point)) -1 -1 ,limit)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
632 |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
633 (defmacro c-go-up-list-forward (&optional pos limit) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
634 "Move the point to the first position after the list sexp containing POS, |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
635 or containing the point if POS is left out. Return t if such a |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
636 position exists, otherwise nil is returned and the point isn't moved. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
637 |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
638 A limit for the search may be given. The start position is assumed to |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
639 be before it." |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
640 (let ((res `(c-safe (goto-char (scan-lists ,(or pos `(point)) 1 1)) t))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
641 (if limit |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
642 `(save-restriction |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
643 (narrow-to-region (point-min) ,limit) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
644 ,res) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
645 res))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
646 |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
647 (defmacro c-go-up-list-backward (&optional pos limit) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
648 "Move the point to the position of the start of the list sexp containing POS, |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
649 or containing the point if POS is left out. Return t if such a |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
650 position exists, otherwise nil is returned and the point isn't moved. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
651 |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
652 A limit for the search may be given. The start position is assumed to |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
653 be after it." |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
654 (let ((res `(c-safe (goto-char (scan-lists ,(or pos `(point)) -1 1)) t))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
655 (if limit |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
656 `(save-restriction |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
657 (narrow-to-region ,limit (point-max)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
658 ,res) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
659 res))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
660 |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
661 (defmacro c-go-down-list-forward (&optional pos limit) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
662 "Move the point to the first position inside the first list sexp after POS, |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
663 or before the point if POS is left out. Return t if such a position |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
664 exists, otherwise nil is returned and the point isn't moved. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
665 |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
666 A limit for the search may be given. The start position is assumed to |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
667 be before it." |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
668 (let ((res `(c-safe (goto-char (scan-lists ,(or pos `(point)) 1 -1)) t))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
669 (if limit |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
670 `(save-restriction |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
671 (narrow-to-region (point-min) ,limit) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
672 ,res) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
673 res))) |
44728
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
|
674 |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
675 (defmacro c-go-down-list-backward (&optional pos limit) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
676 "Move the point to the last position inside the last list sexp before POS, |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
677 or before the point if POS is left out. Return t if such a position |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
678 exists, otherwise nil is returned and the point isn't moved. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
679 |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
680 A limit for the search may be given. The start position is assumed to |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
681 be after it." |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
682 (let ((res `(c-safe (goto-char (scan-lists ,(or pos `(point)) -1 -1)) t))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
683 (if limit |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
684 `(save-restriction |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
685 (narrow-to-region ,limit (point-max)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
686 ,res) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
687 res))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
688 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
689 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
690 (defmacro c-beginning-of-defun-1 () |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
691 ;; Wrapper around beginning-of-defun. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
692 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
693 ;; 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
|
694 ;; 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
|
695 ;; 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
|
696 ;; 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
|
697 ;; (c-beginning-of-defun-1) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
698 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
699 ;; 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
|
700 ;; 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
|
701 ;; `c-parse-state'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
702 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
703 `(progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
704 (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
|
705 c-enable-xemacs-performance-kludge-p) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
706 ,(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
|
707 ;; 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
|
708 ;; 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
|
709 ;; 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
|
710 ;; about as much when braces are not hung. |
77081
e8bd3e011b64
Changes to make `narrow-to-defun' and `mark-defun' work properly in CC
Alan Mackenzie <acm@muc.de>
parents:
75515
diff
changeset
|
711 '(let (beginning-of-defun-function end-of-defun-function |
e8bd3e011b64
Changes to make `narrow-to-defun' and `mark-defun' work properly in CC
Alan Mackenzie <acm@muc.de>
parents:
75515
diff
changeset
|
712 pos) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
713 (while (not pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
714 (save-restriction |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
715 (widen) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
716 (setq pos (c-safe-scan-lists |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
717 (point) -1 (buffer-syntactic-context-depth)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
718 (cond |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
719 ((bobp) (setq pos (point-min))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
720 ((not pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
721 (let ((distance (skip-chars-backward "^{"))) |
80055
1f1aee9ec35e
*** empty log message ***
Juanma Barranquero <lekktu@gmail.com>
parents:
79951
diff
changeset
|
722 ;; unbalanced parenthesis, while invalid C code, |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
723 ;; 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
|
724 (when (zerop distance) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
725 ;; Punt! |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
726 (beginning-of-defun) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
727 (setq pos (point))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
728 ((= pos 0)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
729 ((not (eq (char-after pos) ?{)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
730 (goto-char pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
731 (setq pos nil)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
732 )) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
733 (goto-char pos))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
734 ;; Emacs, which doesn't have buffer-syntactic-context-depth |
77081
e8bd3e011b64
Changes to make `narrow-to-defun' and `mark-defun' work properly in CC
Alan Mackenzie <acm@muc.de>
parents:
75515
diff
changeset
|
735 (let (beginning-of-defun-function end-of-defun-function) |
e8bd3e011b64
Changes to make `narrow-to-defun' and `mark-defun' work properly in CC
Alan Mackenzie <acm@muc.de>
parents:
75515
diff
changeset
|
736 (beginning-of-defun))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
737 ;; 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
|
738 ;; open brace. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
739 (and defun-prompt-regexp |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
740 (looking-at defun-prompt-regexp) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
741 (goto-char (match-end 0))))) |
36920 | 742 |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
743 |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
744 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
75515
b48c6cc5f648
(c-emacs-features): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
75347
diff
changeset
|
745 ;; V i r t u a l S e m i c o l o n s |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
746 ;; |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
747 ;; In most CC Mode languages, statements are terminated explicitly by |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
748 ;; semicolons or closing braces. In some of the CC modes (currently only AWK |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
749 ;; Mode (April 2004)), statements are (or can be) terminated by EOLs. Such a |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
750 ;; statement is said to be terminated by a "virtual semicolon" (VS). A |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
751 ;; statement terminated by an actual semicolon or brace is never considered to |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
752 ;; have a VS. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
753 ;; |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
754 ;; The indentation engine (or whatever) tests for a VS at a specific position |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
755 ;; by invoking the macro `c-at-vsemi-p', which in its turn calls the mode |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
756 ;; specific function (if any) which is the value of the language variable |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
757 ;; `c-at-vsemi-p-fn'. The actual details of what constitutes a VS in a |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
758 ;; language are thus encapsulated in code specific to that language |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
759 ;; (e.g. cc-awk.el). `c-at-vsemi-p' returns non-nil if point (or the optional |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
760 ;; parameter POS) is at a VS, nil otherwise. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
761 ;; |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
762 ;; The language specific function might well do extensive analysis of the |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
763 ;; source text, and may use a cacheing scheme to speed up repeated calls. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
764 ;; |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
765 ;; The "virtual semicolon" lies just after the last non-ws token on the line. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
766 ;; Like POINT, it is considered to lie between two characters. For example, |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
767 ;; at the place shown in the following AWK source line: |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
768 ;; |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
769 ;; kbyte = 1024 # 1000 if you're not picky |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
770 ;; ^ |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
771 ;; | |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
772 ;; Virtual Semicolon |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
773 ;; |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
774 ;; In addition to `c-at-vsemi-p-fn', a mode may need to supply a function for |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
775 ;; `c-vsemi-status-unknown-p-fn'. The macro `c-vsemi-status-unknown-p' is a |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
776 ;; rather recondite kludge. It exists because the function |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
777 ;; `c-beginning-of-statement-1' sometimes tests for VSs as an optimisation, |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
778 ;; but `c-at-vsemi-p' might well need to call `c-beginning-of-statement-1' in |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
779 ;; its calculations, thus potentially leading to infinite recursion. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
780 ;; |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
781 ;; The macro `c-vsemi-status-unknown-p' resolves this problem; it may return |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
782 ;; non-nil at any time; returning nil is a guarantee that an immediate |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
783 ;; invocation of `c-at-vsemi-p' at point will NOT call |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
784 ;; `c-beginning-of-statement-1'. `c-vsemi-status-unknown-p' may not itself |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
785 ;; call `c-beginning-of-statement-1'. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
786 ;; |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
787 ;; The macro `c-vsemi-status-unknown-p' will typically check the cacheing |
75027
9f636bd65206
Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents:
74372
diff
changeset
|
788 ;; scheme used by the `c-at-vsemi-p-fn', hence the name - the status is |
75515
b48c6cc5f648
(c-emacs-features): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
75347
diff
changeset
|
789 ;; "unknown" if there is no cache entry current for the line. |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
790 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
791 |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
792 (defmacro c-at-vsemi-p (&optional pos) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
793 ;; Is there a virtual semicolon (not a real one or a }) at POS (defaults to |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
794 ;; point)? Always returns nil for languages which don't have Virtual |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
795 ;; semicolons. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
796 ;; This macro might do hidden buffer changes. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
797 `(if c-at-vsemi-p-fn |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
798 (funcall c-at-vsemi-p-fn ,@(if pos `(,pos))))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
799 |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
800 (defmacro c-vsemi-status-unknown-p () |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
801 ;; Return NIL only if it can be guaranteed that an immediate |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
802 ;; (c-at-vsemi-p) will NOT call c-beginning-of-statement-1. Otherwise, |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
803 ;; return non-nil. (See comments above). The function invoked by this |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
804 ;; macro MUST NOT UNDER ANY CIRCUMSTANCES itself call |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
805 ;; c-beginning-of-statement-1. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
806 ;; Languages which don't have EOL terminated statements always return NIL |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
807 ;; (they _know_ there's no vsemi ;-). |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
808 `(if c-vsemi-status-unknown-p-fn (funcall c-vsemi-status-unknown-p-fn))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
809 |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
810 |
44728
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 (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
|
812 ;; 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
|
813 ;; `error' but doesn't abort. |
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 `(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
|
815 (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
|
816 (ding))) |
36920 | 817 |
818 (defmacro c-with-syntax-table (table &rest code) | |
819 ;; Temporarily switches to the specified syntax table in a failsafe | |
820 ;; way to execute code. | |
821 `(let ((c-with-syntax-table-orig-table (syntax-table))) | |
822 (unwind-protect | |
823 (progn | |
824 (set-syntax-table ,table) | |
825 ,@code) | |
826 (set-syntax-table c-with-syntax-table-orig-table)))) | |
827 (put 'c-with-syntax-table 'lisp-indent-function 1) | |
828 | |
44728
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
|
829 (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
|
830 "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
|
831 This function skips over horizontal and vertical whitespace and line |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
832 continuations." |
44728
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
|
833 (if limit |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
834 `(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
|
835 (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
|
836 ;; 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
|
837 (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
|
838 (when (and (eq (char-after) ?\\) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
839 (< (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
|
840 (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
|
841 (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
|
842 (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
|
843 '(while (progn |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
844 (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
|
845 (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
|
846 (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
|
847 (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
|
848 (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
|
849 |
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
|
850 (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
|
851 "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
|
852 This function skips over horizontal and vertical whitespace and line |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
853 continuations." |
44728
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
|
854 (if limit |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
855 `(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
|
856 (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
|
857 ;; 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
|
858 (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
|
859 (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
|
860 (eq (char-before) ?\\) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
861 (> (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
|
862 (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
|
863 '(while (progn |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
864 (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
|
865 (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
|
866 (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
|
867 (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
|
868 |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
869 (eval-and-compile |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
870 (defvar c-langs-are-parametric nil)) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
871 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
872 (defmacro c-major-mode-is (mode) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
873 "Return non-nil if the current CC Mode major mode is MODE. |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
874 MODE is either a mode symbol or a list of mode symbols." |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
875 |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
876 (if c-langs-are-parametric |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
877 ;; Inside a `c-lang-defconst'. |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
878 `(c-lang-major-mode-is ,mode) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
879 |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
880 (if (eq (car-safe mode) 'quote) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
881 (let ((mode (eval mode))) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
882 (if (listp mode) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
883 `(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
|
884 `(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
|
885 |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
886 `(let ((mode ,mode)) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
887 (if (listp mode) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
888 (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
|
889 (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
|
890 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
891 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
892 ;; Macros/functions to handle so-called "char properties", which are |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
893 ;; properties set on a single character and that never spread to any |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
894 ;; other characters. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
895 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
896 (eval-and-compile |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
897 ;; 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
|
898 ;; 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
|
899 ;; 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
|
900 ;; Emacs. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
901 (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
|
902 (cc-bytecomp-fboundp 'set-extent-property) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
903 (cc-bytecomp-fboundp 'set-extent-properties) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
904 (cc-bytecomp-fboundp 'make-extent) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
905 (cc-bytecomp-fboundp 'extent-property) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
906 (cc-bytecomp-fboundp 'delete-extent) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
907 (cc-bytecomp-fboundp 'map-extents)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
908 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
909 ;; `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
|
910 ;; make it a function. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
911 (defalias 'c-put-char-property-fun |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
912 (cc-eval-when-compile |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
913 (cond (c-use-extents |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
914 ;; XEmacs. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
915 (byte-compile |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
916 (lambda (pos property value) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
917 (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
|
918 (if ext |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
919 (set-extent-property ext property value) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
920 (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
|
921 (cons property |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
922 (cons value |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
923 '(start-open t |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
924 end-open t))))))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
925 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
926 ((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
|
927 ;; 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
|
928 (byte-compile |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
929 (lambda (pos property value) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
930 (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
|
931 (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
|
932 (or (memq property prop) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
933 (put-text-property pos (1+ pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
934 'rear-nonsticky |
99660
ae9eb12f2b81
(c-put-char-property-fun): Add fallback definition of 'ignore, rather
Glenn Morris <rgm@gnu.org>
parents:
99433
diff
changeset
|
935 (cons property prop))))))) |
ae9eb12f2b81
(c-put-char-property-fun): Add fallback definition of 'ignore, rather
Glenn Morris <rgm@gnu.org>
parents:
99433
diff
changeset
|
936 ;; This won't be used for anything. |
ae9eb12f2b81
(c-put-char-property-fun): Add fallback definition of 'ignore, rather
Glenn Morris <rgm@gnu.org>
parents:
99433
diff
changeset
|
937 (t 'ignore)))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
938 (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
|
939 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
940 (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
|
941 ;; 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
|
942 ;; 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
|
943 ;; 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
|
944 ;; 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
|
945 ;; 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
|
946 ;; PROPERTY is assumed to be constant. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
947 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
948 ;; 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
|
949 ;; 21) then it's assumed that the property is present on it. |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
950 ;; |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
951 ;; This macro does a hidden buffer change. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
952 (setq property (eval property)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
953 (if (or c-use-extents |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
954 (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
|
955 ;; XEmacs and Emacs < 21. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
956 `(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
|
957 ;; 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
|
958 ;; by `text-property-default-nonsticky'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
959 `(let ((-pos- ,pos)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
960 (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
|
961 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
962 (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
|
963 ;; 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
|
964 ;; 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
|
965 ;; assumed to be constant. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
966 (setq property (eval property)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
967 (if c-use-extents |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
968 ;; XEmacs. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
969 `(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
|
970 (if ext (extent-property ext ',property))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
971 ;; Emacs. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
972 `(get-text-property ,pos ',property))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
973 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
974 ;; `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
|
975 ;; 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
|
976 (defalias 'c-clear-char-property-fun |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
977 (cc-eval-when-compile |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
978 (unless (or c-use-extents |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
979 (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
|
980 (byte-compile |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
981 (lambda (pos property) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
982 (when (get-text-property pos property) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
983 (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
|
984 (put-text-property pos (1+ pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
985 'rear-nonsticky |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
986 (delq property (get-text-property |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
987 pos 'rear-nonsticky))))))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
988 (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
|
989 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
990 (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
|
991 ;; 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
|
992 ;; 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
|
993 ;; constant. |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
994 ;; |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
995 ;; This macro does a hidden buffer change. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
996 (setq property (eval property)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
997 (cond (c-use-extents |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
998 ;; XEmacs. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
999 `(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
|
1000 (if ext (delete-extent ext)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1001 ((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
|
1002 ;; 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
|
1003 ;; by `text-property-default-nonsticky'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1004 `(let ((pos ,pos)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1005 (remove-text-properties pos (1+ pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1006 '(,property nil)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1007 (t |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1008 ;; Emacs < 21. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1009 `(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
|
1010 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1011 (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
|
1012 ;; 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
|
1013 ;; 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
|
1014 ;; assumed to be constant. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1015 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1016 ;; 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
|
1017 ;; 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
|
1018 ;; 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
|
1019 ;; `syntax-table'. |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1020 ;; |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1021 ;; This macro does hidden buffer changes. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1022 (setq property (eval property)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1023 (if c-use-extents |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1024 ;; XEmacs. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1025 `(map-extents (lambda (ext ignored) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1026 (delete-extent ext)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1027 nil ,from ,to nil nil ',property) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1028 ;; Emacs. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1029 `(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
|
1030 |
80156
fa9371f081be
Set of changes so that "obtrusive" syntactic elements in a
Alan Mackenzie <acm@muc.de>
parents:
80055
diff
changeset
|
1031 (defun c-clear-char-property-with-value-function (from to property value) |
fa9371f081be
Set of changes so that "obtrusive" syntactic elements in a
Alan Mackenzie <acm@muc.de>
parents:
80055
diff
changeset
|
1032 "Remove all text-properties PROPERTY from the region (FROM, TO) |
fa9371f081be
Set of changes so that "obtrusive" syntactic elements in a
Alan Mackenzie <acm@muc.de>
parents:
80055
diff
changeset
|
1033 which have the value VALUE, as tested by `equal'. These |
fa9371f081be
Set of changes so that "obtrusive" syntactic elements in a
Alan Mackenzie <acm@muc.de>
parents:
80055
diff
changeset
|
1034 properties are assumed to be over individual characters, having |
fa9371f081be
Set of changes so that "obtrusive" syntactic elements in a
Alan Mackenzie <acm@muc.de>
parents:
80055
diff
changeset
|
1035 been put there by c-put-char-property. POINT remains unchanged." |
fa9371f081be
Set of changes so that "obtrusive" syntactic elements in a
Alan Mackenzie <acm@muc.de>
parents:
80055
diff
changeset
|
1036 (let ((place from) end-place) |
fa9371f081be
Set of changes so that "obtrusive" syntactic elements in a
Alan Mackenzie <acm@muc.de>
parents:
80055
diff
changeset
|
1037 (while ; loop round occurrances of (PROPERTY VALUE) |
fa9371f081be
Set of changes so that "obtrusive" syntactic elements in a
Alan Mackenzie <acm@muc.de>
parents:
80055
diff
changeset
|
1038 (progn |
fa9371f081be
Set of changes so that "obtrusive" syntactic elements in a
Alan Mackenzie <acm@muc.de>
parents:
80055
diff
changeset
|
1039 (while ; loop round changes in PROPERTY till we find VALUE |
fa9371f081be
Set of changes so that "obtrusive" syntactic elements in a
Alan Mackenzie <acm@muc.de>
parents:
80055
diff
changeset
|
1040 (and |
fa9371f081be
Set of changes so that "obtrusive" syntactic elements in a
Alan Mackenzie <acm@muc.de>
parents:
80055
diff
changeset
|
1041 (< place to) |
fa9371f081be
Set of changes so that "obtrusive" syntactic elements in a
Alan Mackenzie <acm@muc.de>
parents:
80055
diff
changeset
|
1042 (not (equal (get-text-property place property) value))) |
fa9371f081be
Set of changes so that "obtrusive" syntactic elements in a
Alan Mackenzie <acm@muc.de>
parents:
80055
diff
changeset
|
1043 (setq place (next-single-property-change place property nil to))) |
fa9371f081be
Set of changes so that "obtrusive" syntactic elements in a
Alan Mackenzie <acm@muc.de>
parents:
80055
diff
changeset
|
1044 (< place to)) |
fa9371f081be
Set of changes so that "obtrusive" syntactic elements in a
Alan Mackenzie <acm@muc.de>
parents:
80055
diff
changeset
|
1045 (setq end-place (next-single-property-change place property nil to)) |
fa9371f081be
Set of changes so that "obtrusive" syntactic elements in a
Alan Mackenzie <acm@muc.de>
parents:
80055
diff
changeset
|
1046 (put-text-property place end-place property nil) |
fa9371f081be
Set of changes so that "obtrusive" syntactic elements in a
Alan Mackenzie <acm@muc.de>
parents:
80055
diff
changeset
|
1047 ;; Do we have to do anything with stickiness here? |
fa9371f081be
Set of changes so that "obtrusive" syntactic elements in a
Alan Mackenzie <acm@muc.de>
parents:
80055
diff
changeset
|
1048 (setq place end-place)))) |
fa9371f081be
Set of changes so that "obtrusive" syntactic elements in a
Alan Mackenzie <acm@muc.de>
parents:
80055
diff
changeset
|
1049 |
fa9371f081be
Set of changes so that "obtrusive" syntactic elements in a
Alan Mackenzie <acm@muc.de>
parents:
80055
diff
changeset
|
1050 (defmacro c-clear-char-property-with-value (from to property value) |
fa9371f081be
Set of changes so that "obtrusive" syntactic elements in a
Alan Mackenzie <acm@muc.de>
parents:
80055
diff
changeset
|
1051 "Remove all text-properties PROPERTY from the region [FROM, TO) |
fa9371f081be
Set of changes so that "obtrusive" syntactic elements in a
Alan Mackenzie <acm@muc.de>
parents:
80055
diff
changeset
|
1052 which have the value VALUE, as tested by `equal'. These |
fa9371f081be
Set of changes so that "obtrusive" syntactic elements in a
Alan Mackenzie <acm@muc.de>
parents:
80055
diff
changeset
|
1053 properties are assumed to be over individual characters, having |
fa9371f081be
Set of changes so that "obtrusive" syntactic elements in a
Alan Mackenzie <acm@muc.de>
parents:
80055
diff
changeset
|
1054 been put there by c-put-char-property. POINT remains unchanged." |
fa9371f081be
Set of changes so that "obtrusive" syntactic elements in a
Alan Mackenzie <acm@muc.de>
parents:
80055
diff
changeset
|
1055 (if c-use-extents |
fa9371f081be
Set of changes so that "obtrusive" syntactic elements in a
Alan Mackenzie <acm@muc.de>
parents:
80055
diff
changeset
|
1056 ;; XEmacs |
fa9371f081be
Set of changes so that "obtrusive" syntactic elements in a
Alan Mackenzie <acm@muc.de>
parents:
80055
diff
changeset
|
1057 `(let ((-property- ,property)) |
fa9371f081be
Set of changes so that "obtrusive" syntactic elements in a
Alan Mackenzie <acm@muc.de>
parents:
80055
diff
changeset
|
1058 (map-extents (lambda (ext val) |
fa9371f081be
Set of changes so that "obtrusive" syntactic elements in a
Alan Mackenzie <acm@muc.de>
parents:
80055
diff
changeset
|
1059 (if (equal (extent-property ext -property-) val) |
fa9371f081be
Set of changes so that "obtrusive" syntactic elements in a
Alan Mackenzie <acm@muc.de>
parents:
80055
diff
changeset
|
1060 (delete-extent ext))) |
fa9371f081be
Set of changes so that "obtrusive" syntactic elements in a
Alan Mackenzie <acm@muc.de>
parents:
80055
diff
changeset
|
1061 nil ,from ,to ,value nil -property-)) |
fa9371f081be
Set of changes so that "obtrusive" syntactic elements in a
Alan Mackenzie <acm@muc.de>
parents:
80055
diff
changeset
|
1062 ;; Gnu Emacs |
fa9371f081be
Set of changes so that "obtrusive" syntactic elements in a
Alan Mackenzie <acm@muc.de>
parents:
80055
diff
changeset
|
1063 `(c-clear-char-property-with-value-function ,from ,to ,property ,value))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1064 |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1065 ;; Macros to put overlays (Emacs) or extents (XEmacs) on buffer text. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1066 ;; For our purposes, these are characterized by being possible to |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1067 ;; remove again without affecting the other text properties in the |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1068 ;; buffer that got overridden when they were put. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1069 |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1070 (defmacro c-put-overlay (from to property value) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1071 ;; Put an overlay/extent covering the given range in the current |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1072 ;; buffer. It's currently undefined whether it's front/end sticky |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1073 ;; or not. The overlay/extent object is returned. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1074 (if (cc-bytecomp-fboundp 'make-overlay) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1075 ;; Emacs. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1076 `(let ((ol (make-overlay ,from ,to))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1077 (overlay-put ol ,property ,value) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1078 ol) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1079 ;; XEmacs. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1080 `(let ((ext (make-extent ,from ,to))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1081 (set-extent-property ext ,property ,value) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1082 ext))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1083 |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1084 (defmacro c-delete-overlay (overlay) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1085 ;; Deletes an overlay/extent object previously retrieved using |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1086 ;; `c-put-overlay'. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1087 (if (cc-bytecomp-fboundp 'make-overlay) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1088 ;; Emacs. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1089 `(delete-overlay ,overlay) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1090 ;; XEmacs. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1091 `(delete-extent ,overlay))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1092 |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1093 |
44728
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
|
1094 ;; Make edebug understand the macros. |
71754
60304f6ae360
* progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents:
69140
diff
changeset
|
1095 ;(eval-after-load "edebug" ; 2006-07-09: def-edebug-spec is now in subr.el. |
60304f6ae360
* progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents:
69140
diff
changeset
|
1096 ; '(progn |
60304f6ae360
* progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents:
69140
diff
changeset
|
1097 (def-edebug-spec cc-eval-when-compile t) |
60304f6ae360
* progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents:
69140
diff
changeset
|
1098 (def-edebug-spec c-point t) |
60304f6ae360
* progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents:
69140
diff
changeset
|
1099 (def-edebug-spec c-set-region-active t) |
60304f6ae360
* progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents:
69140
diff
changeset
|
1100 (def-edebug-spec c-safe t) |
60304f6ae360
* progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents:
69140
diff
changeset
|
1101 (def-edebug-spec c-save-buffer-state let*) |
60304f6ae360
* progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents:
69140
diff
changeset
|
1102 (def-edebug-spec c-tentative-buffer-changes t) |
60304f6ae360
* progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents:
69140
diff
changeset
|
1103 (def-edebug-spec c-forward-syntactic-ws t) |
60304f6ae360
* progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents:
69140
diff
changeset
|
1104 (def-edebug-spec c-backward-syntactic-ws t) |
60304f6ae360
* progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents:
69140
diff
changeset
|
1105 (def-edebug-spec c-forward-sexp t) |
60304f6ae360
* progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents:
69140
diff
changeset
|
1106 (def-edebug-spec c-backward-sexp t) |
60304f6ae360
* progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents:
69140
diff
changeset
|
1107 (def-edebug-spec c-up-list-forward t) |
60304f6ae360
* progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents:
69140
diff
changeset
|
1108 (def-edebug-spec c-up-list-backward t) |
60304f6ae360
* progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents:
69140
diff
changeset
|
1109 (def-edebug-spec c-down-list-forward t) |
60304f6ae360
* progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents:
69140
diff
changeset
|
1110 (def-edebug-spec c-down-list-backward t) |
60304f6ae360
* progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents:
69140
diff
changeset
|
1111 (def-edebug-spec c-add-syntax t) |
60304f6ae360
* progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents:
69140
diff
changeset
|
1112 (def-edebug-spec c-add-class-syntax t) |
60304f6ae360
* progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents:
69140
diff
changeset
|
1113 (def-edebug-spec c-benign-error t) |
60304f6ae360
* progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents:
69140
diff
changeset
|
1114 (def-edebug-spec c-with-syntax-table t) |
60304f6ae360
* progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents:
69140
diff
changeset
|
1115 (def-edebug-spec c-skip-ws-forward t) |
60304f6ae360
* progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents:
69140
diff
changeset
|
1116 (def-edebug-spec c-skip-ws-backward t) |
60304f6ae360
* progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents:
69140
diff
changeset
|
1117 (def-edebug-spec c-major-mode-is t) |
60304f6ae360
* progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents:
69140
diff
changeset
|
1118 (def-edebug-spec c-put-char-property t) |
60304f6ae360
* progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents:
69140
diff
changeset
|
1119 (def-edebug-spec c-get-char-property t) |
60304f6ae360
* progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents:
69140
diff
changeset
|
1120 (def-edebug-spec c-clear-char-property t) |
60304f6ae360
* progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents:
69140
diff
changeset
|
1121 (def-edebug-spec c-clear-char-properties t) |
60304f6ae360
* progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents:
69140
diff
changeset
|
1122 (def-edebug-spec c-put-overlay t) |
60304f6ae360
* progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents:
69140
diff
changeset
|
1123 (def-edebug-spec c-delete-overlay 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
|
1124 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1125 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1126 ;;; Functions. |
36920 | 1127 |
1128 ;; Note: All these after the macros, to be on safe side in avoiding | |
1129 ;; bugs where macros are defined too late. These bugs often only show | |
1130 ;; when the files are compiled in a certain order within the same | |
1131 ;; session. | |
1132 | |
26817 | 1133 (defsubst c-end-of-defun-1 () |
1134 ;; 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
|
1135 (let ((start (point))) |
3393922ea102
(c-end-of-defun-1): Fixed forward scanning into
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
1136 ;; 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
|
1137 ;; 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
|
1138 ;; anyway. |
3393922ea102
(c-end-of-defun-1): Fixed forward scanning into
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
1139 (skip-chars-forward "^}") |
3393922ea102
(c-end-of-defun-1): Fixed forward scanning into
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
1140 (c-beginning-of-defun-1) |
3393922ea102
(c-end-of-defun-1): Fixed forward scanning into
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
1141 (if (eq (char-after) ?{) |
3393922ea102
(c-end-of-defun-1): Fixed forward scanning into
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
1142 (c-forward-sexp)) |
3393922ea102
(c-end-of-defun-1): Fixed forward scanning into
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
1143 (if (< (point) start) |
3393922ea102
(c-end-of-defun-1): Fixed forward scanning into
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
1144 (goto-char (point-max))))) |
18720 | 1145 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1146 (defconst c-<-as-paren-syntax '(4 . ?>)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1147 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1148 (defsubst c-mark-<-as-paren (pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1149 ;; Mark the "<" character at POS as an sexp list opener using the |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1150 ;; syntax-table property. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1151 ;; |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1152 ;; This function does a hidden buffer change. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1153 (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
|
1154 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1155 (defconst c->-as-paren-syntax '(5 . ?<)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1156 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1157 (defsubst c-mark->-as-paren (pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1158 ;; Mark the ">" character at POS as an sexp list closer using the |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1159 ;; syntax-table property. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1160 ;; |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1161 ;; This function does a hidden buffer change. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1162 (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
|
1163 |
18720 | 1164 (defsubst c-intersect-lists (list alist) |
1165 ;; return the element of ALIST that matches the first element found | |
1166 ;; in LIST. Uses assq. | |
1167 (let (match) | |
1168 (while (and list | |
1169 (not (setq match (assq (car list) alist)))) | |
1170 (setq list (cdr list))) | |
1171 match)) | |
1172 | |
1173 (defsubst c-lookup-lists (list alist1 alist2) | |
1174 ;; first, find the first entry from LIST that is present in ALIST1, | |
1175 ;; then find the entry in ALIST2 for that entry. | |
1176 (assq (car (c-intersect-lists list alist1)) alist2)) | |
1177 | |
51948
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
1178 (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
|
1179 "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
|
1180 |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1181 LANGELEM is either a cons cell on the \"old\" form given as the first |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1182 argument to lineup functions or a syntactic element on the \"new\" |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1183 form as used in `c-syntactic-element'." |
51948
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
1184 (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
|
1185 |
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
1186 (defsubst c-langelem-pos (langelem) |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1187 "Return the anchor position in LANGELEM, or nil if there is none. |
51948
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
1188 |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1189 LANGELEM is either a cons cell on the \"old\" form given as the first |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1190 argument to lineup functions or a syntactic element on the \"new\" |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1191 form as used in `c-syntactic-element'." |
51948
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
1192 (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
|
1193 (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
|
1194 (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
|
1195 |
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
1196 (defun c-langelem-col (langelem &optional preserve-point) |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1197 "Return the column of the anchor position in LANGELEM. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1198 Also move the point to that position unless PRESERVE-POINT is non-nil. |
51948
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
1199 |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1200 LANGELEM is either a cons cell on the \"old\" form given as the first |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1201 argument to lineup functions or a syntactic element on the \"new\" |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1202 form as used in `c-syntactic-element'." |
51948
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
1203 (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
|
1204 (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
|
1205 (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
|
1206 (progn |
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
1207 (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
|
1208 (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
|
1209 (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
|
1210 (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
|
1211 0))) |
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
1212 |
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
1213 (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
|
1214 "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
|
1215 |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1216 LANGELEM is typically a syntactic element on the \"new\" form as used |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1217 in `c-syntactic-element'. It may also be a cons cell as passed in the |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1218 first argument to lineup functions, but then the returned value always |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1219 will be nil." |
51948
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
1220 (car-safe (cdr-safe (cdr-safe langelem)))) |
18720 | 1221 |
1222 (defsubst c-keep-region-active () | |
1223 ;; Do whatever is necessary to keep the region active in XEmacs. | |
36920 | 1224 ;; This is not needed for Emacs. |
18720 | 1225 (and (boundp 'zmacs-region-stays) |
1226 (setq zmacs-region-stays t))) | |
1227 | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1228 (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
|
1229 (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
|
1230 (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
|
1231 (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
|
1232 (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
|
1233 (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
|
1234 (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
|
1235 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1236 (defsubst c-mode-symbol (suffix) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1237 "Prefix the current mode prefix (e.g. \"c-\") to SUFFIX and return |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1238 the corresponding symbol." |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1239 (or c-buffer-is-cc-mode |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1240 (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
|
1241 (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
|
1242 (or mode-prefix |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1243 (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
|
1244 c-buffer-is-cc-mode)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1245 (intern (concat mode-prefix suffix)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1246 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1247 (defsubst c-mode-var (suffix) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1248 "Prefix the current mode prefix (e.g. \"c-\") to SUFFIX and return |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1249 the value of the variable with that name." |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1250 (symbol-value (c-mode-symbol suffix))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1251 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1252 (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
|
1253 "Return non-nil if position POS in the current buffer has any of the |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1254 faces in the list FACES." |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1255 (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
|
1256 (if (consp pos-faces) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1257 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1258 (while (and pos-faces |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1259 (not (memq (car pos-faces) faces))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1260 (setq pos-faces (cdr pos-faces))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1261 pos-faces) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1262 (memq pos-faces faces)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1263 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1264 (defsubst c-face-name-p (facename) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1265 ;; 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
|
1266 ;; 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
|
1267 ;; 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
|
1268 ;; 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
|
1269 ;; face names. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1270 (memq facename (face-list))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1271 |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1272 (defun c-concat-separated (list separator) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1273 "Like `concat' on LIST, but separate each element with SEPARATOR. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1274 Notably, null elements in LIST are ignored." |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1275 (mapconcat 'identity (delete nil (append list nil)) separator)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1276 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1277 (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
|
1278 "Make a regexp that matches all the strings the list. |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1279 Duplicates and nil elements in the list are removed. The resulting |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1280 regexp may contain zero or more submatch expressions. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1281 |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1282 If ADORN is t there will be at least one submatch and the first |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1283 surrounds the matched alternative, and the regexp will also not match |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1284 a prefix of any identifier. Adorned regexps cannot be appended. The |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1285 language variable `c-nonsymbol-key' is used to make the adornment. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1286 |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1287 A value 'appendable for ADORN is like above, but all alternatives in |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1288 the list that end with a word constituent char will have \\> appended |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1289 instead, so that the regexp remains appendable. Note that this |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1290 variant doesn't always guarantee that an identifier prefix isn't |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1291 matched since the symbol constituent '_' is normally considered a |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1292 nonword token by \\>. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1293 |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1294 The optional MODE specifies the language to get `c-nonsymbol-key' from |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1295 when it's needed. The default is the current language taken from |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1296 `c-buffer-is-cc-mode'." |
53073
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52610
diff
changeset
|
1297 |
51887
a39d64d1eb50
(c-make-keywords-re): Don't use delete-duplicates.
Richard M. Stallman <rms@gnu.org>
parents:
51829
diff
changeset
|
1298 (let (unique) |
a39d64d1eb50
(c-make-keywords-re): Don't use delete-duplicates.
Richard M. Stallman <rms@gnu.org>
parents:
51829
diff
changeset
|
1299 (dolist (elt list) |
a39d64d1eb50
(c-make-keywords-re): Don't use delete-duplicates.
Richard M. Stallman <rms@gnu.org>
parents:
51829
diff
changeset
|
1300 (unless (member elt unique) |
a39d64d1eb50
(c-make-keywords-re): Don't use delete-duplicates.
Richard M. Stallman <rms@gnu.org>
parents:
51829
diff
changeset
|
1301 (push elt unique))) |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1302 (setq list (delete nil unique))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1303 (if list |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1304 (let (re) |
53073
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52610
diff
changeset
|
1305 |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1306 (if (eq adorn 'appendable) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1307 ;; This is kludgy but it works: Search for a string that |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1308 ;; doesn't occur in any word in LIST. Append it to all |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1309 ;; the alternatives where we want to add \>. Run through |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1310 ;; `regexp-opt' and then replace it with \>. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1311 (let ((unique "") pos) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1312 (while (let (found) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1313 (setq unique (concat unique "@") |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1314 pos list) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1315 (while (and pos |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1316 (if (string-match unique (car pos)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1317 (progn (setq found t) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1318 nil) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1319 t)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1320 (setq pos (cdr pos))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1321 found)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1322 (setq pos list) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1323 (while pos |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1324 (if (string-match "\\w\\'" (car pos)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1325 (setcar pos (concat (car pos) unique))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1326 (setq pos (cdr pos))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1327 (setq re (regexp-opt list)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1328 (setq pos 0) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1329 (while (string-match unique re pos) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1330 (setq pos (+ (match-beginning 0) 2) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1331 re (replace-match "\\>" t t re)))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1332 |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1333 (setq re (regexp-opt list))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1334 |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1335 ;; Emacs 20 and XEmacs (all versions so far) has a buggy |
53073
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52610
diff
changeset
|
1336 ;; 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
|
1337 ;; 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
|
1338 ;; 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
|
1339 (let (fail-list) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52610
diff
changeset
|
1340 (while list |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52610
diff
changeset
|
1341 (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
|
1342 (not (string-match (concat "\\`\\(" re "\\)\\'") |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52610
diff
changeset
|
1343 (car list))) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52610
diff
changeset
|
1344 (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
|
1345 (setq list (cdr list))) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52610
diff
changeset
|
1346 (when fail-list |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52610
diff
changeset
|
1347 (setq re (concat re |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52610
diff
changeset
|
1348 "\\|" |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1349 (mapconcat |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1350 (if (eq adorn 'appendable) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1351 (lambda (str) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1352 (if (string-match "\\w\\'" str) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1353 (concat (regexp-quote str) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1354 "\\>") |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1355 (regexp-quote str))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1356 'regexp-quote) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1357 (sort fail-list |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1358 (lambda (a b) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1359 (> (length a) (length b)))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1360 "\\|"))))) |
53073
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52610
diff
changeset
|
1361 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1362 ;; 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
|
1363 ;; 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
|
1364 ;; top level grouping "shy". |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1365 (cond ((eq adorn 'appendable) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1366 (concat "\\(" re "\\)")) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1367 (adorn |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1368 (concat "\\(" re "\\)" |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1369 "\\(" |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1370 (c-get-lang-constant 'c-nonsymbol-key nil mode) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1371 "\\|$\\)")) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1372 (t |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1373 re))) |
53073
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52610
diff
changeset
|
1374 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1375 ;; Produce a regexp that matches nothing. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1376 (if adorn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1377 "\\(\\<\\>\\)" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1378 "\\<\\>"))) |
53073
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52610
diff
changeset
|
1379 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1380 (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
|
1381 |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1382 (defun c-make-bare-char-alt (chars &optional inverted) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1383 "Make a character alternative string from the list of characters CHARS. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1384 The returned string is of the type that can be used with |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1385 `skip-chars-forward' and `skip-chars-backward'. If INVERTED is |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1386 non-nil, a caret is prepended to invert the set." |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1387 ;; This function ought to be in the elisp core somewhere. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1388 (let ((str (if inverted "^" "")) char char2) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1389 (setq chars (sort (append chars nil) `<)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1390 (while chars |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1391 (setq char (pop chars)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1392 (if (memq char '(?\\ ?^ ?-)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1393 ;; Quoting necessary (this method only works in the skip |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1394 ;; functions). |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1395 (setq str (format "%s\\%c" str char)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1396 (setq str (format "%s%c" str char))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1397 ;; Check for range. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1398 (setq char2 char) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1399 (while (and chars (>= (1+ char2) (car chars))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1400 (setq char2 (pop chars))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1401 (unless (= char char2) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1402 (if (< (1+ char) char2) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1403 (setq str (format "%s-%c" str char2)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1404 (push char2 chars)))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1405 str)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1406 |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1407 ;; Leftovers from (X)Emacs 19 compatibility. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1408 (defalias 'c-regexp-opt 'regexp-opt) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1409 (defalias 'c-regexp-opt-depth 'regexp-opt-depth) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1410 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1411 |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1412 ;; 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
|
1413 |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1414 (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
|
1415 |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1416 (defconst c-emacs-features |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1417 (let (list) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1418 |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1419 (if (boundp 'infodock-version) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1420 ;; 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
|
1421 (setq list (cons 'infodock list))) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1422 |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1423 ;; XEmacs uses 8-bit modify-syntax-entry flags. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1424 ;; Emacs uses a 1-bit flag. We will have to set up our |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1425 ;; syntax tables differently to handle this. |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1426 (let ((table (copy-syntax-table)) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1427 entry) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1428 (modify-syntax-entry ?a ". 12345678" table) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1429 (cond |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1430 ;; Emacs |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1431 ((arrayp table) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1432 (setq entry (aref table ?a)) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1433 ;; 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
|
1434 (if (consp entry) (setq entry (car entry)))) |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1435 ;; XEmacs |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1436 ((fboundp 'get-char-table) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1437 (setq entry (get-char-table ?a table))) |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1438 ;; incompatible |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1439 (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
|
1440 (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
|
1441 '8-bit |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1442 '1-bit) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1443 list))) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1444 |
97430
d76aacb7f6e4
(c-emacs-features): Check beginning-of-defun-raw instead of
Chong Yidong <cyd@stupidchicken.com>
parents:
96384
diff
changeset
|
1445 ;; In Emacs >= 23, beginning-of-defun-raw passes its argument to |
d76aacb7f6e4
(c-emacs-features): Check beginning-of-defun-raw instead of
Chong Yidong <cyd@stupidchicken.com>
parents:
96384
diff
changeset
|
1446 ;; beginning-of-defun-function. Assume end-of-defun does likewise. |
96384
59d141ae8c74
cc-mode.el (c-mode-base-map): Don't bind C-M-[ae] to the CC Mode specific
Alan Mackenzie <acm@muc.de>
parents:
94673
diff
changeset
|
1447 (let ((beginning-of-defun-function |
59d141ae8c74
cc-mode.el (c-mode-base-map): Don't bind C-M-[ae] to the CC Mode specific
Alan Mackenzie <acm@muc.de>
parents:
94673
diff
changeset
|
1448 (lambda (&optional arg) |
97441
3f5d22fa3877
(c-emacs-features): argumentative-bod-function: bind mark-ring to avoid
Alan Mackenzie <acm@muc.de>
parents:
97430
diff
changeset
|
1449 (not (eq arg nil)))) |
3f5d22fa3877
(c-emacs-features): argumentative-bod-function: bind mark-ring to avoid
Alan Mackenzie <acm@muc.de>
parents:
97430
diff
changeset
|
1450 mark-ring) |
97430
d76aacb7f6e4
(c-emacs-features): Check beginning-of-defun-raw instead of
Chong Yidong <cyd@stupidchicken.com>
parents:
96384
diff
changeset
|
1451 (save-excursion |
d76aacb7f6e4
(c-emacs-features): Check beginning-of-defun-raw instead of
Chong Yidong <cyd@stupidchicken.com>
parents:
96384
diff
changeset
|
1452 (if (beginning-of-defun-raw 1) |
d76aacb7f6e4
(c-emacs-features): Check beginning-of-defun-raw instead of
Chong Yidong <cyd@stupidchicken.com>
parents:
96384
diff
changeset
|
1453 (setq list (cons 'argumentative-bod-function list))))) |
96384
59d141ae8c74
cc-mode.el (c-mode-base-map): Don't bind C-M-[ae] to the CC Mode specific
Alan Mackenzie <acm@muc.de>
parents:
94673
diff
changeset
|
1454 |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1455 (let ((buf (generate-new-buffer " test")) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1456 parse-sexp-lookup-properties |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1457 parse-sexp-ignore-comments |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1458 lookup-syntax-properties) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1459 (save-excursion |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1460 (set-buffer buf) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1461 (set-syntax-table (make-syntax-table)) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1462 |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1463 ;; 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
|
1464 ;; buffer has been made current. (Specifically, |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1465 ;; `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
|
1466 (setq parse-sexp-lookup-properties t |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1467 parse-sexp-ignore-comments t |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1468 lookup-syntax-properties t) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1469 |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1470 ;; 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
|
1471 (modify-syntax-entry ?< ".") |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1472 (modify-syntax-entry ?> ".") |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1473 (insert "<()>") |
67350
946119cea694
(c-emacs-features): Don't assume point-min==1.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
67252
diff
changeset
|
1474 (c-mark-<-as-paren (point-min)) |
946119cea694
(c-emacs-features): Don't assume point-min==1.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
67252
diff
changeset
|
1475 (c-mark->-as-paren (+ 3 (point-min))) |
946119cea694
(c-emacs-features): Don't assume point-min==1.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
67252
diff
changeset
|
1476 (goto-char (point-min)) |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1477 (c-forward-sexp) |
67350
946119cea694
(c-emacs-features): Don't assume point-min==1.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
67252
diff
changeset
|
1478 (if (= (point) (+ 4 (point-min))) |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1479 (setq list (cons 'syntax-properties list)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1480 (error (concat |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1481 "CC Mode is incompatible with this version of Emacs - " |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1482 "support for the `syntax-table' text property " |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1483 "is required."))) |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1484 |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1485 ;; 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
|
1486 (c-safe |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1487 (modify-syntax-entry ?x "!") |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1488 (if (string-match "\\s!" "x") |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1489 (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
|
1490 |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1491 ;; 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
|
1492 (c-safe |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1493 (modify-syntax-entry ?x "|") |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1494 (if (string-match "\\s|" "x") |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1495 (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
|
1496 |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1497 ;; See if POSIX char classes work. |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1498 (when (and (string-match "[[:alpha:]]" "a") |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1499 ;; 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
|
1500 ;; 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
|
1501 ;; `skip-chars-backward'. |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1502 (progn |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1503 (delete-region (point-min) (point-max)) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1504 (insert "foo123") |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1505 (skip-chars-backward "[:alnum:]") |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1506 (bobp)) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1507 (= (skip-chars-forward "[:alpha:]") 3)) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1508 (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
|
1509 |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1510 ;; See if `open-paren-in-column-0-is-defun-start' exists and |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1511 ;; isn't buggy (Emacs >= 21.4). |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1512 (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
|
1513 (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
|
1514 (parse-sexp-ignore-comments t)) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1515 (delete-region (point-min) (point-max)) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1516 (set-syntax-table (make-syntax-table)) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1517 (modify-syntax-entry ?\' "\"") |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1518 (cond |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1519 ;; 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
|
1520 ;; 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
|
1521 ((memq '8-bit list) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1522 (modify-syntax-entry ?/ ". 1456") |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1523 (modify-syntax-entry ?* ". 23")) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1524 ;; Emacs |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1525 ((memq '1-bit list) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1526 (modify-syntax-entry ?/ ". 124b") |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1527 (modify-syntax-entry ?* ". 23"))) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1528 (modify-syntax-entry ?\n "> b") |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1529 (insert "/* '\n () */") |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1530 (backward-sexp) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1531 (if (bobp) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1532 (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
|
1533 |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1534 (set-buffer-modified-p nil)) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1535 (kill-buffer buf)) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1536 |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1537 ;; See if `parse-partial-sexp' returns the eighth element. |
67811
e7ac0fc47db5
(c-emacs-features): Do parse-partial-sexp at point, in case of narrowing.
Richard M. Stallman <rms@gnu.org>
parents:
67350
diff
changeset
|
1538 (if (c-safe (>= (length (save-excursion (parse-partial-sexp (point) (point)))) |
e7ac0fc47db5
(c-emacs-features): Do parse-partial-sexp at point, in case of narrowing.
Richard M. Stallman <rms@gnu.org>
parents:
67350
diff
changeset
|
1539 10)) |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1540 (setq list (cons 'pps-extended-state list)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1541 (error (concat |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1542 "CC Mode is incompatible with this version of Emacs - " |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1543 "`parse-partial-sexp' has to return at least 10 elements."))) |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1544 |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1545 ;;(message "c-emacs-features: %S" list) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1546 list) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1547 "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
|
1548 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
|
1549 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
|
1550 might be present: |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1551 |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1552 '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
|
1553 '1-bit 1 bit syntax entry flags (Emacs style). |
96384
59d141ae8c74
cc-mode.el (c-mode-base-map): Don't bind C-M-[ae] to the CC Mode specific
Alan Mackenzie <acm@muc.de>
parents:
94673
diff
changeset
|
1554 'argumentative-bod-function beginning-of-defun passes ARG through |
59d141ae8c74
cc-mode.el (c-mode-base-map): Don't bind C-M-[ae] to the CC Mode specific
Alan Mackenzie <acm@muc.de>
parents:
94673
diff
changeset
|
1555 to a non-null beginning-of-defun-function. It is assumed |
59d141ae8c74
cc-mode.el (c-mode-base-map): Don't bind C-M-[ae] to the CC Mode specific
Alan Mackenzie <acm@muc.de>
parents:
94673
diff
changeset
|
1556 the end-of-defun does the same thing. |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1557 'syntax-properties It works to override the syntax for specific characters |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1558 in the buffer with the 'syntax-table property. It's |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1559 always set - CC Mode no longer works in emacsen without |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1560 this feature. |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1561 '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
|
1562 (i.e. the syntax class `!'). |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1563 '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
|
1564 (i.e. the syntax class `|'). |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1565 'pps-extended-state `parse-partial-sexp' returns a list with at least 10 |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1566 elements, i.e. it contains the position of the start of |
75515
b48c6cc5f648
(c-emacs-features): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
75347
diff
changeset
|
1567 the last comment or string. It's always set - CC Mode |
b48c6cc5f648
(c-emacs-features): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
75347
diff
changeset
|
1568 no longer works in emacsen without this feature. |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1569 '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
|
1570 '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
|
1571 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
|
1572 '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
|
1573 |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1574 '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
|
1575 |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1576 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1577 ;;; Some helper constants. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1578 |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1579 ;; 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
|
1580 ;; them to handle extended charsets correctly. |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1581 (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
|
1582 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1583 (defconst c-alpha "[:alpha:]") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1584 (defconst c-alnum "[:alnum:]") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1585 (defconst c-digit "[:digit:]") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1586 (defconst c-upper "[:upper:]") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1587 (defconst c-lower "[:lower:]")) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1588 (defconst c-alpha "a-zA-Z") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1589 (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
|
1590 (defconst c-digit "0-9") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1591 (defconst c-upper "A-Z") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1592 (defconst c-lower "a-z")) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1593 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1594 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1595 ;;; System for handling language dependent constants. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1596 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1597 ;; 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
|
1598 ;; 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
|
1599 ;; 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
|
1600 ;; 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
|
1601 ;; 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
|
1602 ;; 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
|
1603 ;; 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
|
1604 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1605 ;; 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
|
1606 ;; 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
|
1607 ;; 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
|
1608 ;; `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
|
1609 ;; 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
|
1610 ;; 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
|
1611 ;; `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
|
1612 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1613 ;; `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
|
1614 ;; 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
|
1615 ;; 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
|
1616 ;; 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
|
1617 ;; 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
|
1618 ;; 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
|
1619 ;; 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
|
1620 ;; 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
|
1621 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1622 ;; 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
|
1623 ;; 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
|
1624 ;; 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
|
1625 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1626 ;; 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
|
1627 ;; 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
|
1628 ;; (`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
|
1629 ;; examples. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1630 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1631 (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
|
1632 "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
|
1633 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
|
1634 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
|
1635 `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
|
1636 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
|
1637 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
|
1638 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1639 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
|
1640 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
|
1641 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
|
1642 system." |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1643 (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
|
1644 (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
|
1645 (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
|
1646 (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
|
1647 (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
|
1648 (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
|
1649 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1650 (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
|
1651 ;; 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
|
1652 ;; 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
|
1653 ;; `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
|
1654 ;; stored in compiled files. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1655 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1656 ;; 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
|
1657 ;; 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
|
1658 ;; 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
|
1659 ;; 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
|
1660 ;; 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
|
1661 ;; 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
|
1662 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1663 (defvar c-lang-const-expansion nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1664 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1665 (defsubst c-get-current-file () |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1666 ;; 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
|
1667 (let ((file (cond |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1668 (load-in-progress |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1669 ;; Being loaded. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1670 load-file-name) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1671 ((and (boundp 'byte-compile-dest-file) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1672 (stringp byte-compile-dest-file)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1673 ;; Being compiled. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1674 byte-compile-dest-file) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1675 (t |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1676 ;; Being evaluated interactively. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1677 (buffer-file-name))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1678 (and file |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1679 (file-name-sans-extension |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1680 (file-name-nondirectory file))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1681 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1682 (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
|
1683 "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
|
1684 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
|
1685 itself is evaluated." |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1686 ;; 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
|
1687 ;; `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
|
1688 (eval form)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1689 |
99409
aca04343781b
(cl-macroexpand-all): Declare.
Glenn Morris <rgm@gnu.org>
parents:
97971
diff
changeset
|
1690 ;; Only used at compile time - suppress "might not be defined at runtime". |
99433
526e8371e23f
(cl-macroexpand-all): Fix declaration.
Glenn Morris <rgm@gnu.org>
parents:
99409
diff
changeset
|
1691 (declare-function cl-macroexpand-all "cl-extra" (form &optional env)) |
99409
aca04343781b
(cl-macroexpand-all): Declare.
Glenn Morris <rgm@gnu.org>
parents:
97971
diff
changeset
|
1692 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1693 (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
|
1694 "Set the language specific values of the language constant NAME. |
75027
9f636bd65206
Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents:
74372
diff
changeset
|
1695 The second argument can optionally be a docstring. The rest of the |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1696 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
|
1697 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
|
1698 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
|
1699 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
|
1700 evaluate to get the value. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1701 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1702 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
|
1703 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
|
1704 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1705 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
|
1706 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
|
1707 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
|
1708 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1709 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
|
1710 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
|
1711 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
|
1712 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
|
1713 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1714 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
|
1715 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
|
1716 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
|
1717 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
|
1718 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
|
1719 reference the constant. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1720 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1721 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
|
1722 \(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
|
1723 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
|
1724 gotten in another earlier loaded file. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1725 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1726 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
|
1727 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
|
1728 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
|
1729 earlier definition will not affect `c-lang-const' on the same |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1730 constant. A file is identified by its base name." |
51714
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 (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
|
1733 ;; 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
|
1734 ;; `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
|
1735 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1736 ;; (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
|
1737 ;; `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
|
1738 ;; 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
|
1739 ;; 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
|
1740 ;; 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
|
1741 ;; `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
|
1742 ;; 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
|
1743 ;; 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
|
1744 ;; language constant source definitions.) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1745 (c-lang-const-expansion 'call) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1746 (c-langs-are-parametric t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1747 bindings |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1748 pre-files) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1749 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1750 (or (symbolp name) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1751 (error "Not a symbol: %s" name)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1752 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1753 (when (stringp (car-safe args)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1754 ;; 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
|
1755 ;; 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
|
1756 ;; format in the source. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1757 (put sym 'variable-documentation (car args)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1758 (setq args (cdr args))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1759 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1760 (or args |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1761 (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
|
1762 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1763 ;; 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
|
1764 ;; 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
|
1765 ;; 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
|
1766 (while args |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1767 (let ((assigned-mode |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1768 (cond ((eq (car args) t) t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1769 ((symbolp (car args)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1770 (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
|
1771 "-mode")))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1772 ((listp (car args)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1773 (mapcar (lambda (lang) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1774 (or (symbolp lang) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1775 (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
|
1776 (car args))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1777 (intern (concat (symbol-name lang) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1778 "-mode"))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1779 (car args))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1780 (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
|
1781 (car args))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1782 val) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1783 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1784 (or (cdr args) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1785 (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
|
1786 (setq args (cdr args) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1787 val (car args)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1788 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1789 ;; 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
|
1790 ;; 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
|
1791 ;; forms, to be specific), so make sure the bindings in the |
75027
9f636bd65206
Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents:
74372
diff
changeset
|
1792 ;; expansion below don't contain any backquote stuff. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1793 ;; (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
|
1794 ;; 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
|
1795 ;; `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
|
1796 ;; 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
|
1797 (setq val (cl-macroexpand-all val)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1798 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1799 (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
|
1800 args (cdr args)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1801 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1802 ;; 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
|
1803 ;; 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
|
1804 ;; `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
|
1805 ;; order. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1806 (setq pre-files (nreverse |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1807 ;; 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
|
1808 (mapcar 'car (get sym 'source)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1809 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1810 `(eval-and-compile |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1811 (c-define-lang-constant ',name ',bindings |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1812 ,@(and pre-files `(',pre-files)))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1813 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1814 (put 'c-lang-defconst 'lisp-indent-function 1) |
71754
60304f6ae360
* progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents:
69140
diff
changeset
|
1815 ;(eval-after-load "edebug" ; 2006-07-09: def-edebug-spec is now in subr.el. |
60304f6ae360
* progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents:
69140
diff
changeset
|
1816 ; ' |
60304f6ae360
* progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents:
69140
diff
changeset
|
1817 (def-edebug-spec c-lang-defconst |
60304f6ae360
* progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents:
69140
diff
changeset
|
1818 (&define name [&optional stringp] [&rest sexp def-form])) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1819 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1820 (defun c-define-lang-constant (name bindings &optional pre-files) |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1821 ;; Used by `c-lang-defconst'. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1822 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1823 (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
|
1824 (source (get sym 'source)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1825 (file (intern |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1826 (or (c-get-current-file) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1827 (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
|
1828 (elem (assq file source))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1829 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1830 ;;(when (cdr-safe elem) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1831 ;; (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
|
1832 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1833 ;; 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
|
1834 ;; `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
|
1835 ;; 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
|
1836 (unless elem |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1837 (while pre-files |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1838 (unless (assq (car pre-files) source) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1839 (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
|
1840 (setq pre-files (cdr pre-files))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1841 (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
|
1842 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1843 (setcdr elem bindings) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1844 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1845 ;; 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
|
1846 ;; value it has. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1847 (set sym nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1848 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1849 ;; 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
|
1850 (let ((agenda (get sym 'dependents)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1851 (visited (make-vector 101 0)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1852 ptr) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1853 (while agenda |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1854 (setq sym (car agenda) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1855 agenda (cdr agenda)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1856 (intern (symbol-name sym) visited) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1857 (set sym nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1858 (setq ptr (get sym 'dependents)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1859 (while ptr |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1860 (setq sym (car ptr) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1861 ptr (cdr ptr)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1862 (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
|
1863 (setq agenda (cons sym agenda)))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1864 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1865 name)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1866 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1867 (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
|
1868 "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
|
1869 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
|
1870 \"-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
|
1871 `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
|
1872 language. NAME and LANG are not evaluated so they should not be |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1873 quoted." |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1874 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1875 (or (symbolp name) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1876 (error "Not a symbol: %s" name)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1877 (or (symbolp lang) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1878 (error "Not a symbol: %s" lang)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1879 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1880 (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
|
1881 mode source-files args) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1882 |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1883 (when lang |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1884 (setq mode (intern (concat (symbol-name lang) "-mode"))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1885 (unless (get mode 'c-mode-prefix) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1886 (error |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1887 "Unknown language %S since it got no `c-mode-prefix' property" |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1888 (symbol-name lang)))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1889 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1890 (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
|
1891 ;; 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
|
1892 ;; 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
|
1893 ;; `source' property. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1894 `',(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
|
1895 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1896 (let ((file (c-get-current-file))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1897 (if file (setq file (intern file))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1898 ;; 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
|
1899 ;; 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
|
1900 ;; 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
|
1901 ;; are no file dependencies needed. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1902 (setq source-files (nreverse |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1903 ;; 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
|
1904 (apply 'nconc |
a39d64d1eb50
(c-make-keywords-re): Don't use delete-duplicates.
Richard M. Stallman <rms@gnu.org>
parents:
51829
diff
changeset
|
1905 (mapcar (lambda (elem) |
a39d64d1eb50
(c-make-keywords-re): Don't use delete-duplicates.
Richard M. Stallman <rms@gnu.org>
parents:
51829
diff
changeset
|
1906 (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
|
1907 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
|
1908 (list (car elem)))) |
a39d64d1eb50
(c-make-keywords-re): Don't use delete-duplicates.
Richard M. Stallman <rms@gnu.org>
parents:
51829
diff
changeset
|
1909 (get sym 'source)))))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1910 |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1911 ;; Make some effort to do a compact call to |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1912 ;; `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
|
1913 (setq args (and mode `(',mode))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1914 (if (or source-files args) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1915 (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
|
1916 args))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1917 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1918 (if (or (eq c-lang-const-expansion 'call) |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1919 (and (not c-lang-const-expansion) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1920 (not mode)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1921 load-in-progress |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1922 (not (boundp 'byte-compile-dest-file)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1923 (not (stringp byte-compile-dest-file))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1924 ;; Either a straight call is requested in the context, or |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1925 ;; we're in an "uncontrolled" context and got no language, |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1926 ;; or we're not being byte compiled so the compile time |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1927 ;; stuff below is unnecessary. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1928 `(c-get-lang-constant ',name ,@args) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1929 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1930 ;; 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
|
1931 ;; 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
|
1932 ;; otherwise it's evaluated at runtime. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1933 `(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
|
1934 (cc-eval-when-compile |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1935 (c-get-lang-constant ',name ,@args)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1936 (c-get-lang-constant ',name ,@args)))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1937 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1938 (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
|
1939 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1940 (defun c-get-lang-constant (name &optional source-files mode) |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1941 ;; Used by `c-lang-const'. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1942 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1943 (or mode |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1944 (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
|
1945 (error "No current language")) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1946 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1947 (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
|
1948 (source (get sym 'source)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1949 elem |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1950 (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
|
1951 (caar c-lang-constants-under-evaluation)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1952 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1953 ;; 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
|
1954 ;; being evaluated in. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1955 (when eval-in-sym |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1956 (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
|
1957 (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
|
1958 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1959 ;; 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
|
1960 ;; 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
|
1961 (while source-files |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1962 (unless (assq (car source-files) source) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1963 (put sym 'source |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1964 (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
|
1965 ;; 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
|
1966 ;; 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
|
1967 ;; 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
|
1968 ;; 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
|
1969 (set sym nil)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1970 (setq source-files (cdr source-files))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1971 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1972 (if (and (boundp sym) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1973 (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
|
1974 (cdr elem) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1975 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1976 ;; 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
|
1977 ;; 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
|
1978 ;; 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
|
1979 ;; 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
|
1980 (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
|
1981 (source-pos |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1982 (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
|
1983 (cons sym (vector source nil)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1984 ;; 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
|
1985 ;; 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
|
1986 ;; the recording of dependencies above correct. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1987 (c-lang-constants-under-evaluation |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1988 (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
|
1989 (fallback (get mode 'c-fallback-mode)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1990 value |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1991 ;; 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
|
1992 ;; 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
|
1993 (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
|
1994 (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
|
1995 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1996 (if (if fallback |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1997 (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
|
1998 (and |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1999 ;; 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
|
2000 ;; 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
|
2001 ;; 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
|
2002 (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
|
2003 (cdr source-pos) mode nil name)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
2004 c-lang-constants) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
2005 ;; 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
|
2006 ;; original position. Note that |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
2007 ;; `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
|
2008 ;; language parameterization takes place. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
2009 (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
|
2010 (setcdr source-pos backup-source-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
2011 fallback t name)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
2012 c-lang-constants))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
2013 ;; 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
|
2014 (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
|
2015 (cdr source-pos) mode t name)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
2016 c-lang-constants)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
2017 (error |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
2018 "`%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
|
2019 name mode)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
2020 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
2021 (condition-case err |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
2022 (setq value (eval value)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
2023 (error |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
2024 ;; 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
|
2025 ;; 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
|
2026 ;; some caller higher up. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
2027 (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
|
2028 sym mode) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
2029 (makunbound sym) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
2030 (signal (car err) (cdr err)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
2031 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
2032 (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
|
2033 value)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
2034 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
2035 (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
|
2036 ;; 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
|
2037 ;; 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
|
2038 ;; 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
|
2039 ;; 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
|
2040 ;; 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
|
2041 ;; `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
|
2042 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
2043 ;; 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
|
2044 ;; 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
|
2045 ;; 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
|
2046 ;; 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
|
2047 ;; nested bindings alist. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
2048 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
2049 ;; 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
|
2050 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
2051 (catch 'found |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
2052 (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
|
2053 (assignment-entry (elt source-pos 1)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
2054 assignment) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
2055 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
2056 (while (if assignment-entry |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
2057 t |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
2058 ;; 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
|
2059 ;; 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
|
2060 ;; there's at least one. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
2061 (when file-entry |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
2062 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
2063 (unless (aset source-pos 1 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
2064 (setq assignment-entry (cdar file-entry))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
2065 ;; 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
|
2066 ;; been loaded. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
2067 (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
|
2068 (c-lang-constants-under-evaluation nil)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
2069 ;;(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
|
2070 ;; "value for language constant %s") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
2071 ;; file name) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
2072 (load file)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
2073 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
2074 (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
|
2075 ;; 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
|
2076 ;; constant as expected. The situation is |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
2077 ;; 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
|
2078 ;; 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
|
2079 ;; 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
|
2080 ;; 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
|
2081 ;; assignment that matches no language. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
2082 (setcdr (car file-entry) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
2083 (setq assignment-entry (list (list nil)))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
2084 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
2085 (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
|
2086 t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
2087 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
2088 (setq assignment (car assignment-entry)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
2089 (aset source-pos 1 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
2090 (setq assignment-entry (cdr assignment-entry))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
2091 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
2092 (when (if (listp (car assignment)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
2093 (memq mode (car assignment)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
2094 match-any-lang) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
2095 (throw 'found (cdr assignment)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
2096 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
2097 c-lang-constants))) |
24282 | 2098 |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
2099 (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
|
2100 ;; `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
|
2101 ;; `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
|
2102 ;; 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
|
2103 ;; 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
|
2104 ;; 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
|
2105 (unless (listp mode) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
2106 (setq mode (list mode))) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
2107 (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
|
2108 (while (if (memq buf-mode mode) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
2109 (progn |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
2110 (setq match t) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
2111 nil) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
2112 (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
|
2113 match)) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
2114 |
18720 | 2115 |
36920 | 2116 (cc-provide 'cc-defs) |
38422
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
36920
diff
changeset
|
2117 |
93975
1e3a407766b9
Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92148
diff
changeset
|
2118 ;; arch-tag: 3bb2629d-dd84-4ff0-ad39-584be0fe3cda |
18720 | 2119 ;;; cc-defs.el ends here |