1 ;;; cc-defs.el --- definitions for CC Mode
3 ;; Copyright (C) 1985,87,92,93,94,95,96,97 Free Software Foundation, Inc.
5 ;; Authors: 1992-1997 Barry A. Warsaw
6 ;; 1987 Dave Detlefs and Stewart Clamen
7 ;; 1985 Richard M. Stallman
8 ;; Maintainer: cc-mode-help@python.org
9 ;; Created: 22-Apr-1997 (split from cc-mode.el)
11 ;; Keywords: c languages oop
13 ;; This file is part of GNU Emacs.
15 ;; GNU Emacs is free software; you can redistribute it and/or modify
16 ;; it under the terms of the GNU General Public License as published by
17 ;; the Free Software Foundation; either version 2, or (at your option)
20 ;; GNU Emacs is distributed in the hope that it will be useful,
21 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
22 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 ;; GNU General Public License for more details.
25 ;; You should have received a copy of the GNU General Public License
26 ;; along with GNU Emacs; see the file COPYING. If not, write to the
27 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
28 ;; Boston, MA 02111-1307, USA.
31 ;; Figure out what features this Emacs has
32 (defconst c-emacs-features
33 (let ((infodock-p (boundp 'infodock-version
))
35 ;; XEmacs 19 and beyond use 8-bit modify-syntax-entry flags.
36 ;; Emacs 19 uses a 1-bit flag. We will have to set up our
37 ;; syntax tables differently to handle this.
38 (let ((table (copy-syntax-table))
40 (modify-syntax-entry ?a
". 12345678" table
)
42 ;; XEmacs 19, and beyond Emacs 19.34
44 (setq entry
(aref table ?a
))
45 ;; In Emacs, table entries are cons cells
46 (if (consp entry
) (setq entry
(car entry
))))
48 ((fboundp 'get-char-table
) (setq entry
(get-char-table ?a table
)))
49 ;; before and including Emacs 19.34
50 ((and (fboundp 'char-table-p
)
52 (setq entry
(car (char-table-range table
[?a
]))))
54 (t (error "CC Mode is incompatible with this version of Emacs")))
55 (if (= (logand (lsh entry -
16) 255) 255)
59 (list comments
'infodock
)
61 "A list of features extant in the Emacs you are using.
62 There are many flavors of Emacs out there, each with different
63 features supporting those needed by CC Mode. Here's the current
64 supported list, along with the values for this variable:
70 Infodock (based on XEmacs) has an additional symbol on this list:
75 (defsubst c-point
(position)
76 ;; Returns the value of point at certain commonly referenced POSITIONs.
77 ;; POSITION can be one of the following symbols:
79 ;; bol -- beginning of line
81 ;; bod -- beginning of defun
82 ;; boi -- back to indentation
83 ;; ionl -- indentation of next line
84 ;; iopl -- indentation of previous line
85 ;; bonl -- beginning of next line
86 ;; bopl -- beginning of previous line
88 ;; This function does not modify point or mark.
91 ((eq position
'bol
) (beginning-of-line))
92 ((eq position
'eol
) (end-of-line))
95 ;; if defun-prompt-regexp is non-nil, b-o-d won't leave us at
97 (and defun-prompt-regexp
98 (looking-at defun-prompt-regexp
)
99 (goto-char (match-end 0)))
101 ((eq position
'boi
) (back-to-indentation))
102 ((eq position
'bonl
) (forward-line 1))
103 ((eq position
'bopl
) (forward-line -
1))
106 (back-to-indentation))
109 (back-to-indentation))
110 (t (error "unknown buffer position requested: %s" position
))
116 (defmacro c-safe
(&rest body
)
117 ;; safely execute BODY, return nil if an error occurred
118 (` (condition-case nil
122 (defmacro c-add-syntax
(symbol &optional relpos
)
123 ;; a simple macro to append the syntax in symbol to the syntax list.
124 ;; try to increase performance by using this macro
125 (` (setq syntax
(cons (cons (, symbol
) (, relpos
)) syntax
))))
127 (defsubst c-auto-newline
()
128 ;; if auto-newline feature is turned on, insert a newline character
129 ;; and return t, otherwise return nil.
134 (defsubst c-intersect-lists
(list alist
)
135 ;; return the element of ALIST that matches the first element found
136 ;; in LIST. Uses assq.
139 (not (setq match
(assq (car list
) alist
))))
140 (setq list
(cdr list
)))
143 (defsubst c-lookup-lists
(list alist1 alist2
)
144 ;; first, find the first entry from LIST that is present in ALIST1,
145 ;; then find the entry in ALIST2 for that entry.
146 (assq (car (c-intersect-lists list alist1
)) alist2
))
148 (defsubst c-langelem-col
(langelem &optional preserve-point
)
149 ;; convenience routine to return the column of langelem's relpos.
150 ;; Leaves point at the relpos unless preserve-point is non-nil.
151 (let ((here (point)))
152 (goto-char (cdr langelem
))
153 (prog1 (current-column)
158 (defsubst c-update-modeline
()
159 ;; set the c-auto-hungry-string for the correct designation on the modeline
160 (setq c-auto-hungry-string
162 (if c-hungry-delete-key
"/ah" "/a")
163 (if c-hungry-delete-key
"/h" nil
)))
164 (force-mode-line-update))
166 (defsubst c-keep-region-active
()
167 ;; Do whatever is necessary to keep the region active in XEmacs.
168 ;; Ignore byte-compiler warnings you might see. This is not needed
170 (and (boundp 'zmacs-region-stays
)
171 (setq zmacs-region-stays t
)))
175 ;;; cc-defs.el ends here