summaryrefslogtreecommitdiff
path: root/lisp/progmodes/cc-defs.el
diff options
context:
space:
mode:
authorBarry A. Warsaw <barry@zope.org>1999-02-08 16:53:18 +0000
committerBarry A. Warsaw <barry@zope.org>1999-02-08 16:53:18 +0000
commit0ec8351b955949a9d992fe033b0b61c04a76b2fa (patch)
treeb0b445d26a17cdd86442e73731c25d547a8dfe7d /lisp/progmodes/cc-defs.el
parent32348c138b896b3a19e2814aaefd8e12cf0178ae (diff)
downloademacs-0ec8351b955949a9d992fe033b0b61c04a76b2fa.tar.gz
Installed CC Mode 5.25.
Diffstat (limited to 'lisp/progmodes/cc-defs.el')
-rw-r--r--lisp/progmodes/cc-defs.el66
1 files changed, 61 insertions, 5 deletions
diff --git a/lisp/progmodes/cc-defs.el b/lisp/progmodes/cc-defs.el
index 2aea9d9989d..2ae6c7bdcf0 100644
--- a/lisp/progmodes/cc-defs.el
+++ b/lisp/progmodes/cc-defs.el
@@ -2,10 +2,11 @@
;; Copyright (C) 1985,87,92,93,94,95,96,97,98 Free Software Foundation, Inc.
-;; Authors: 1992-1997 Barry A. Warsaw
+;; Authors: 1998 Barry A. Warsaw and Martin Stjernholm
+;; 1992-1997 Barry A. Warsaw
;; 1987 Dave Detlefs and Stewart Clamen
;; 1985 Richard M. Stallman
-;; Maintainer: cc-mode-help@python.org
+;; Maintainer: bug-cc-mode@gnu.org
;; Created: 22-Apr-1997 (split from cc-mode.el)
;; Version: See cc-mode.el
;; Keywords: c languages oop
@@ -28,6 +29,25 @@
;; Boston, MA 02111-1307, USA.
+;; Get all the necessary compile time definitions.
+(require 'custom)
+(require 'cc-menus)
+(require 'derived) ;only necessary in Emacs 20
+
+;; cc-mode-19.el contains compatibility macros that should be compiled
+;; in if needed.
+(if (or (not (fboundp 'functionp))
+ (not (condition-case nil
+ (progn (char-before) t)
+ (error nil)))
+ (not (condition-case nil
+ (progn (char-after) t)
+ (error nil)))
+ (not (fboundp 'when))
+ (not (fboundp 'unless)))
+ (require 'cc-mode-19))
+
+
(defsubst c-point (position)
;; Returns the value of point at certain commonly referenced POSITIONs.
;; POSITION can be one of the following symbols:
@@ -35,6 +55,7 @@
;; bol -- beginning of line
;; eol -- end of line
;; bod -- beginning of defun
+ ;; eod -- end of defun
;; boi -- back to indentation
;; ionl -- indentation of next line
;; iopl -- indentation of previous line
@@ -55,14 +76,14 @@
((eq position 'ionl)
(forward-line 1)
(back-to-indentation))
+ ((eq position 'eod) (c-end-of-defun))
((eq position 'bod)
(if (and (fboundp 'buffer-syntactic-context-depth)
c-enable-xemacs-performance-kludge-p)
;; XEmacs only. This can improve the performance of
;; c-parse-state to between 3 and 60 times faster when
- ;; braces are hung. It can cause c-parse-state to be
- ;; slightly slower when braces are not hung, but general
- ;; editing appears to be still about as fast.
+ ;; braces are hung. It can also degrade performance by
+ ;; about as much when braces are not hung.
(let (pos)
(while (not pos)
(save-restriction
@@ -106,12 +127,31 @@
(point)
(goto-char here))))
+
(defmacro c-safe (&rest body)
;; safely execute BODY, return nil if an error occurred
(` (condition-case nil
(progn (,@ body))
(error nil))))
+(defmacro c-forward-sexp (&optional arg)
+ ;; like forward-sexp except
+ ;; 1. this is much stripped down from the XEmacs version
+ ;; 2. this cannot be used as a command, so we're insulated from
+ ;; XEmacs' losing efforts to make forward-sexp more user
+ ;; friendly
+ ;; 3. Preserves the semantics most of CC Mode is based on
+ (or arg (setq arg 1))
+ `(goto-char (or (scan-sexps (point) ,arg)
+ ,(if (numberp arg)
+ (if (> arg 0) `(point-max) `(point-min))
+ `(if (> ,arg 0) (point-max) (point-min))))))
+
+(defmacro c-backward-sexp (&optional arg)
+ ;; See c-forward-sexp and reverse directions
+ (or arg (setq arg 1))
+ `(c-forward-sexp ,(if (numberp arg) (- arg) `(- ,arg))))
+
(defmacro c-add-syntax (symbol &optional relpos)
;; a simple macro to append the syntax in symbol to the syntax list.
;; try to increase performance by using this macro
@@ -163,6 +203,22 @@
(and (boundp 'zmacs-region-stays)
(setq zmacs-region-stays t)))
+(defsubst c-region-is-active-p ()
+ ;; Return t when the region is active. The determination of region
+ ;; activeness is different in both Emacs and XEmacs.
+ (cond
+ ;; XEmacs
+ ((and (fboundp 'region-active-p)
+ zmacs-regions)
+ (region-active-p))
+ ;; Emacs
+ ((boundp 'mark-active) mark-active)
+ ;; fallback; shouldn't get here
+ (t (mark t))))
+
+(defsubst c-major-mode-is (mode)
+ (eq (derived-mode-class major-mode) mode))
+
(provide 'cc-defs)
;;; cc-defs.el ends here