annotate lisp/progmodes/cc-defs.el @ 37072:08152533da68

(${TIT}): Fix whitespace.
author Eli Zaretskii <eliz@gnu.org>
date Fri, 30 Mar 2001 08:27:56 +0000
parents 32a4317c6aa5
children 7a94f1c588c4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
3 ;; Copyright (C) 1985,1987,1992-2001 Free Software Foundation, Inc.
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4
30404
3393922ea102 (c-end-of-defun-1): Fixed forward scanning into
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
5 ;; Authors: 2000- Martin Stjernholm
3393922ea102 (c-end-of-defun-1): Fixed forward scanning into
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
6 ;; 1998-1999 Barry A. Warsaw and Martin Stjernholm
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21112
diff changeset
7 ;; 1992-1997 Barry A. Warsaw
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8 ;; 1987 Dave Detlefs and Stewart Clamen
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9 ;; 1985 Richard M. Stallman
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21112
diff changeset
10 ;; Maintainer: bug-cc-mode@gnu.org
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 ;; Created: 22-Apr-1997 (split from cc-mode.el)
20141
1a85b213eb6d Remove version number.
Karl Heuer <kwzh@gnu.org>
parents: 20140
diff changeset
12 ;; Version: See cc-mode.el
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 ;; Keywords: c languages oop
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15 ;; This file is part of GNU Emacs.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;; GNU Emacs is free software; you can redistribute it and/or modify
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; it under the terms of the GNU General Public License as published by
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 ;; the Free Software Foundation; either version 2, or (at your option)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 ;; any later version.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 ;; GNU Emacs is distributed in the hope that it will be useful,
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25 ;; GNU General Public License for more details.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27 ;; You should have received a copy of the GNU General Public License
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
28 ;; along with this program; see the file COPYING. If not, write to
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
29 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30 ;; Boston, MA 02111-1307, USA.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
32 (eval-when-compile
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
33 (let ((load-path
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
34 (if (and (boundp 'byte-compile-dest-file)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
35 (stringp byte-compile-dest-file))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
36 (cons (file-name-directory byte-compile-dest-file) load-path)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
37 load-path)))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
38 (require 'cc-bytecomp)))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21112
diff changeset
39
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
40 ;; cc-mode-19.el contains compatibility macros that should be used if
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
41 ;; needed.
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
42 (eval-and-compile
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
43 (if (or (not (fboundp 'functionp))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
44 (not (condition-case nil
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
45 (progn (eval '(char-before)) t)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
46 (error nil)))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
47 (not (condition-case nil
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
48 (progn (eval '(char-after)) t)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
49 (error nil)))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
50 (not (fboundp 'when))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
51 (not (fboundp 'unless)))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
52 (cc-load "cc-mode-19")))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
53
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
54 ;; Silence the compiler.
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
55 (cc-bytecomp-defvar c-enable-xemacs-performance-kludge-p) ; In cc-vars.el
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
56 (cc-bytecomp-defun buffer-syntactic-context-depth) ; XEmacs
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
57 (cc-bytecomp-defun region-active-p) ; XEmacs
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
58 (cc-bytecomp-defvar zmacs-region-stays) ; XEmacs
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
59 (cc-bytecomp-defvar zmacs-regions) ; XEmacs
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
60 (cc-bytecomp-defvar mark-active) ; Emacs
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
61 (cc-bytecomp-defun scan-lists) ; 5 args in XEmacs, 3 in Emacs
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
62 (require 'derived) ; Only necessary in Emacs
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21112
diff changeset
63
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21112
diff changeset
64
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
65 ;;; Macros.
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
66
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
67 ;;; Helpers for building regexps.
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
68 (defmacro c-paren-re (re)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
69 `(concat "\\(" ,re "\\)"))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
70 (defmacro c-identifier-re (re)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
71 `(concat "\\<\\(" ,re "\\)\\>[^_]"))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
72
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
73 (defmacro c-point (position &optional point)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
74 ;; Returns the value of certain commonly referenced POSITIONs
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
75 ;; relative to POINT. The current point is used if POINT isn't
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
76 ;; specified. POSITION can be one of the following symbols:
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 ;;
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 ;; bol -- beginning of line
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79 ;; eol -- end of line
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 ;; bod -- beginning of defun
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21112
diff changeset
81 ;; eod -- end of defun
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 ;; boi -- back to indentation
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83 ;; ionl -- indentation of next line
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 ;; iopl -- indentation of previous line
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85 ;; bonl -- beginning of next line
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86 ;; bopl -- beginning of previous line
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87 ;;
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 ;; This function does not modify point or mark.
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
89 `(save-excursion
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
90 ,(if point `(goto-char ,point))
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
91 ,(if (and (eq (car-safe position) 'quote)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
92 (symbolp (eval position)))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
93 (let ((position (eval position)))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
94 (cond
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
95 ((eq position 'bol) `(beginning-of-line))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
96 ((eq position 'eol) `(end-of-line))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
97 ((eq position 'boi) `(back-to-indentation))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
98 ((eq position 'bonl) `(forward-line 1))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
99 ((eq position 'bopl) `(forward-line -1))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
100 ((eq position 'bod) `(c-beginning-of-defun-1))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
101 ((eq position 'eod) `(c-end-of-defun-1))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
102 ((eq position 'iopl) `(progn
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
103 (forward-line -1)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
104 (back-to-indentation)))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
105 ((eq position 'ionl) `(progn
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
106 (forward-line 1)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
107 (back-to-indentation)))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
108 (t (error "unknown buffer position requested: %s" position))))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
109 ;;(message "c-point long expansion")
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
110 `(let ((position ,position))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
111 (cond
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
112 ((eq position 'bol) (beginning-of-line))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
113 ((eq position 'eol) (end-of-line))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
114 ((eq position 'boi) (back-to-indentation))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
115 ((eq position 'bonl) (forward-line 1))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
116 ((eq position 'bopl) (forward-line -1))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
117 ((eq position 'bod) (c-beginning-of-defun-1))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
118 ((eq position 'eod) (c-end-of-defun-1))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
119 ((eq position 'iopl) (progn
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
120 (forward-line -1)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
121 (back-to-indentation)))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
122 ((eq position 'ionl) (progn
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
123 (forward-line 1)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
124 (back-to-indentation)))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
125 (t (error "unknown buffer position requested: %s" position)))))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
126 (point)))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128 (defmacro c-safe (&rest body)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129 ;; safely execute BODY, return nil if an error occurred
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
130 `(condition-case nil
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
131 (progn ,@body)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
132 (error nil)))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
133
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
134 (defmacro c-forward-sexp (&optional arg)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
135 ;; like forward-sexp except
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
136 ;; 1. this is much stripped down from the XEmacs version
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
137 ;; 2. this cannot be used as a command, so we're insulated from
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
138 ;; XEmacs' losing efforts to make forward-sexp more user
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
139 ;; friendly
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
140 ;; 3. Preserves the semantics most of CC Mode is based on
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
141 (or arg (setq arg 1))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
142 `(goto-char (or (scan-sexps (point) ,arg)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
143 ,(if (numberp arg)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
144 (if (> arg 0) `(point-max) `(point-min))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
145 `(if (> ,arg 0) (point-max) (point-min))))))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
146
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
147 (defmacro c-backward-sexp (&optional arg)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
148 ;; See c-forward-sexp and reverse directions
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
149 (or arg (setq arg 1))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
150 `(c-forward-sexp ,(if (numberp arg) (- arg) `(- ,arg))))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
151
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
152 (defmacro c-add-syntax (symbol &optional relpos)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
153 ;; a simple macro to append the syntax in symbol to the syntax list.
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
154 ;; try to increase performance by using this macro
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
155 `(setq syntax (cons (cons ,symbol ,relpos) syntax)))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
156
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
157 (defmacro c-add-class-syntax (symbol classkey)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
158 ;; The inclass and class-close syntactic symbols are added in
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
159 ;; several places and some work is needed to fix everything.
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
160 ;; Therefore it's collected here. This is a macro mostly because
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
161 ;; c-add-syntax doesn't work otherwise.
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
162 `(save-restriction
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
163 (widen)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
164 (let ((symbol ,symbol)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
165 (classkey ,classkey)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
166 inexpr)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
167 (goto-char (aref classkey 1))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
168 (if (and (eq symbol 'inclass) (= (point) (c-point 'boi)))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
169 (c-add-syntax symbol (point))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
170 (c-add-syntax symbol (aref classkey 0))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
171 (if (and c-inexpr-class-key
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
172 (setq inexpr (c-looking-at-inexpr-block))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
173 (/= (cdr inexpr) (c-point 'boi (cdr inexpr))))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
174 (c-add-syntax 'inexpr-class))))))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
175
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
176 (defmacro c-update-modeline ()
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
177 ;; set the c-auto-hungry-string for the correct designation on the modeline
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
178 `(progn
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
179 (setq c-auto-hungry-string
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
180 (if c-auto-newline
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
181 (if c-hungry-delete-key "/ah" "/a")
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
182 (if c-hungry-delete-key "/h" nil)))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
183 (force-mode-line-update)))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
184
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
185 (defmacro c-with-syntax-table (table &rest code)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
186 ;; Temporarily switches to the specified syntax table in a failsafe
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
187 ;; way to execute code.
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
188 `(let ((c-with-syntax-table-orig-table (syntax-table)))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
189 (unwind-protect
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
190 (progn
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
191 (set-syntax-table ,table)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
192 ,@code)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
193 (set-syntax-table c-with-syntax-table-orig-table))))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
194 (put 'c-with-syntax-table 'lisp-indent-function 1)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
195
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
196 ;;; Inline functions.
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
197
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
198 ;; Note: All these after the macros, to be on safe side in avoiding
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
199 ;; bugs where macros are defined too late. These bugs often only show
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
200 ;; when the files are compiled in a certain order within the same
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
201 ;; session.
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
202
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
203 (defsubst c-beginning-of-defun-1 ()
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
204 ;; Wrapper around beginning-of-defun.
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
205 ;;
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
206 ;; NOTE: This function should contain the only explicit use of
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
207 ;; beginning-of-defun in CC Mode. Eventually something better than
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
208 ;; b-o-d will be available and this should be the only place the
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
209 ;; code needs to change. Everything else should use
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
210 ;; (c-beginning-of-defun-1)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
211 (if (and (fboundp 'buffer-syntactic-context-depth)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
212 c-enable-xemacs-performance-kludge-p)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
213 ;; XEmacs only. This can improve the performance of
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
214 ;; c-parse-state to between 3 and 60 times faster when
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
215 ;; braces are hung. It can also degrade performance by
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
216 ;; about as much when braces are not hung.
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
217 (let (pos)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
218 (while (not pos)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
219 (save-restriction
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
220 (widen)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
221 (setq pos (scan-lists (point) -1
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
222 (buffer-syntactic-context-depth)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
223 nil t)))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
224 (cond
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
225 ((bobp) (setq pos (point-min)))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
226 ((not pos)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
227 (let ((distance (skip-chars-backward "^{")))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
228 ;; unbalanced parenthesis, while illegal C code,
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
229 ;; shouldn't cause an infloop! See unbal.c
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
230 (when (zerop distance)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
231 ;; Punt!
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
232 (beginning-of-defun)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
233 (setq pos (point)))))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
234 ((= pos 0))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
235 ((not (eq (char-after pos) ?{))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
236 (goto-char pos)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
237 (setq pos nil))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
238 ))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
239 (goto-char pos))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
240 ;; Emacs, which doesn't have buffer-syntactic-context-depth
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
241 (beginning-of-defun))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
242 ;; if defun-prompt-regexp is non-nil, b-o-d won't leave us at the
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
243 ;; open brace.
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
244 (and defun-prompt-regexp
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
245 (looking-at defun-prompt-regexp)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
246 (goto-char (match-end 0))))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
247
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
248 (defsubst c-end-of-defun-1 ()
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
249 ;; 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
250 (let ((start (point)))
3393922ea102 (c-end-of-defun-1): Fixed forward scanning into
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
251 ;; 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
252 ;; 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
253 ;; anyway.
3393922ea102 (c-end-of-defun-1): Fixed forward scanning into
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
254 (skip-chars-forward "^}")
3393922ea102 (c-end-of-defun-1): Fixed forward scanning into
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
255 (c-beginning-of-defun-1)
3393922ea102 (c-end-of-defun-1): Fixed forward scanning into
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
256 (if (eq (char-after) ?{)
3393922ea102 (c-end-of-defun-1): Fixed forward scanning into
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
257 (c-forward-sexp))
3393922ea102 (c-end-of-defun-1): Fixed forward scanning into
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
258 (if (< (point) start)
3393922ea102 (c-end-of-defun-1): Fixed forward scanning into
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
259 (goto-char (point-max)))))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
260
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
261 (defsubst c-forward-comment (count)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
262 ;; Insulation from various idiosyncrasies in implementations of
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
263 ;; `forward-comment'.
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
264 ;;
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
265 ;; Note: Some emacsen considers incorrectly that any line comment
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
266 ;; ending with a backslash continues to the next line. I can't
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
267 ;; think of any way to work around that in a reliable way without
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
268 ;; changing the buffer though. Suggestions welcome. ;)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
269 ;;
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
270 ;; Another note: When moving backwards over a block comment, there's
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
271 ;; a bug in forward-comment that can make it stop at "/*" inside a
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
272 ;; line comment. Haven't yet found a reasonably cheap way to kludge
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
273 ;; around that one either. :\
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
274 (let ((here (point)))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
275 (if (>= count 0)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
276 (when (forward-comment count)
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
277 ;; Emacs includes the ending newline in a b-style (c++)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
278 ;; comment, but XEmacs doesn't. We depend on the Emacs
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
279 ;; behavior (which also is symmetric).
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
280 (if (and (eolp) (nth 7 (parse-partial-sexp here (point))))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
281 (condition-case nil (forward-char 1)))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
282 t)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
283 ;; When we got newline terminated comments,
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
284 ;; forward-comment in all supported emacsen so far will
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
285 ;; stop at eol of each line not ending with a comment when
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
286 ;; moving backwards. The following corrects for it when
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
287 ;; count is -1. The other common case, when count is
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
288 ;; large and negative, works regardless. It's too much
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
289 ;; work to correct for the rest of the cases.
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
290 (skip-chars-backward " \t\n\r\f")
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
291 (if (bobp)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
292 ;; Some emacsen return t when moving backwards at bob.
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
293 nil
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
294 (re-search-forward "[\n\r]" here t)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
295 (if (forward-comment count)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
296 (if (eolp) (forward-comment -1) t))))))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
297
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
298 (defsubst c-intersect-lists (list alist)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
299 ;; return the element of ALIST that matches the first element found
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
300 ;; in LIST. Uses assq.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
301 (let (match)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
302 (while (and list
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
303 (not (setq match (assq (car list) alist))))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
304 (setq list (cdr list)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
305 match))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
306
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
307 (defsubst c-lookup-lists (list alist1 alist2)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
308 ;; first, find the first entry from LIST that is present in ALIST1,
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
309 ;; then find the entry in ALIST2 for that entry.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
310 (assq (car (c-intersect-lists list alist1)) alist2))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
311
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
312 (defsubst c-langelem-col (langelem &optional preserve-point)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
313 ;; convenience routine to return the column of langelem's relpos.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
314 ;; Leaves point at the relpos unless preserve-point is non-nil.
30404
3393922ea102 (c-end-of-defun-1): Fixed forward scanning into
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
315 (if (cdr langelem)
3393922ea102 (c-end-of-defun-1): Fixed forward scanning into
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
316 (let ((here (point)))
3393922ea102 (c-end-of-defun-1): Fixed forward scanning into
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
317 (goto-char (cdr langelem))
3393922ea102 (c-end-of-defun-1): Fixed forward scanning into
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
318 (prog1 (current-column)
3393922ea102 (c-end-of-defun-1): Fixed forward scanning into
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
319 (if preserve-point
3393922ea102 (c-end-of-defun-1): Fixed forward scanning into
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
320 (goto-char here))
3393922ea102 (c-end-of-defun-1): Fixed forward scanning into
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
321 ))
3393922ea102 (c-end-of-defun-1): Fixed forward scanning into
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
322 0))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
323
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
324 (defsubst c-keep-region-active ()
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
325 ;; Do whatever is necessary to keep the region active in XEmacs.
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
326 ;; This is not needed for Emacs.
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
327 (and (boundp 'zmacs-region-stays)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
328 (setq zmacs-region-stays t)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
329
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21112
diff changeset
330 (defsubst c-region-is-active-p ()
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21112
diff changeset
331 ;; Return t when the region is active. The determination of region
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21112
diff changeset
332 ;; activeness is different in both Emacs and XEmacs.
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21112
diff changeset
333 (cond
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21112
diff changeset
334 ;; XEmacs
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21112
diff changeset
335 ((and (fboundp 'region-active-p)
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
336 (boundp 'zmacs-regions)
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21112
diff changeset
337 zmacs-regions)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21112
diff changeset
338 (region-active-p))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21112
diff changeset
339 ;; Emacs
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21112
diff changeset
340 ((boundp 'mark-active) mark-active)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21112
diff changeset
341 ;; fallback; shouldn't get here
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21112
diff changeset
342 (t (mark t))))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21112
diff changeset
343
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21112
diff changeset
344 (defsubst c-major-mode-is (mode)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21112
diff changeset
345 (eq (derived-mode-class major-mode) mode))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21112
diff changeset
346
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
347
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
348 (cc-provide 'cc-defs)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
349 ;;; cc-defs.el ends here