aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1998-02-17 07:06:17 +0000
committerRichard M. Stallman1998-02-17 07:06:17 +0000
commitd5436a295ebecaee604c27d007c4566d067ed975 (patch)
tree2bca9565067f02e73e748417194dfda9c2310980
parent28c236dee385e1101cfaba57bbf92a25180f7be7 (diff)
downloademacs-d5436a295ebecaee604c27d007c4566d067ed975.tar.gz
emacs-d5436a295ebecaee604c27d007c4566d067ed975.zip
(c-point): In XEmacs, use scan-lists + buffer-syntactic-context-depth.
(c-emacs-features): Added autoload cookie.
-rw-r--r--lisp/progmodes/cc-defs.el56
1 files changed, 47 insertions, 9 deletions
diff --git a/lisp/progmodes/cc-defs.el b/lisp/progmodes/cc-defs.el
index fcd7b408a17..c7b62b8cb79 100644
--- a/lisp/progmodes/cc-defs.el
+++ b/lisp/progmodes/cc-defs.el
@@ -1,6 +1,6 @@
1;;; cc-defs.el --- definitions for CC Mode 1;;; cc-defs.el --- definitions for CC Mode
2 2
3;; Copyright (C) 1985,87,92,93,94,95,96,97 Free Software Foundation, Inc. 3;; Copyright (C) 1985,87,92,93,94,95,96,97,98 Free Software Foundation, Inc.
4 4
5;; Authors: 1992-1997 Barry A. Warsaw 5;; Authors: 1992-1997 Barry A. Warsaw
6;; 1987 Dave Detlefs and Stewart Clamen 6;; 1987 Dave Detlefs and Stewart Clamen
@@ -29,6 +29,7 @@
29 29
30 30
31;; Figure out what features this Emacs has 31;; Figure out what features this Emacs has
32;;;###autoload
32(defconst c-emacs-features 33(defconst c-emacs-features
33 (let ((infodock-p (boundp 'infodock-version)) 34 (let ((infodock-p (boundp 'infodock-version))
34 (comments 35 (comments
@@ -90,14 +91,6 @@ Infodock (based on XEmacs) has an additional symbol on this list:
90 (cond 91 (cond
91 ((eq position 'bol) (beginning-of-line)) 92 ((eq position 'bol) (beginning-of-line))
92 ((eq position 'eol) (end-of-line)) 93 ((eq position 'eol) (end-of-line))
93 ((eq position 'bod)
94 (beginning-of-defun)
95 ;; if defun-prompt-regexp is non-nil, b-o-d won't leave us at
96 ;; the open brace.
97 (and defun-prompt-regexp
98 (looking-at defun-prompt-regexp)
99 (goto-char (match-end 0)))
100 )
101 ((eq position 'boi) (back-to-indentation)) 94 ((eq position 'boi) (back-to-indentation))
102 ((eq position 'bonl) (forward-line 1)) 95 ((eq position 'bonl) (forward-line 1))
103 ((eq position 'bopl) (forward-line -1)) 96 ((eq position 'bopl) (forward-line -1))
@@ -107,6 +100,51 @@ Infodock (based on XEmacs) has an additional symbol on this list:
107 ((eq position 'ionl) 100 ((eq position 'ionl)
108 (forward-line 1) 101 (forward-line 1)
109 (back-to-indentation)) 102 (back-to-indentation))
103 ((eq position 'bod)
104 (if (and (fboundp 'buffer-syntactic-context-depth)
105 c-enable-xemacs-performance-kludge-p)
106 ;; XEmacs only. This can improve the performance of
107 ;; c-parse-state to between 3 and 60 times faster when
108 ;; braces are hung. It can cause c-parse-state to be
109 ;; slightly slower when braces are not hung, but general
110 ;; editing appears to be still about as fast.
111 (let (pos)
112 (while (not pos)
113 (save-restriction
114 (widen)
115 (setq pos (scan-lists (point) -1
116 (buffer-syntactic-context-depth)
117 nil t)))
118 (cond
119 ((bobp) (setq pos (point-min)))
120 ((not pos)
121 (let ((distance (skip-chars-backward "^{")))
122 ;; unbalanced parenthesis, while illegal C code,
123 ;; shouldn't cause an infloop! See unbal.c
124 (when (zerop distance)
125 ;; Punt!
126 (beginning-of-defun)
127 (setq pos (point)))))
128 ((= pos 0))
129 ((not (eq (char-after pos) ?{))
130 (goto-char pos)
131 (setq pos nil))
132 ))
133 (goto-char pos))
134 ;; Emacs, which doesn't have buffer-syntactic-context-depth
135 ;;
136 ;; NOTE: This should be the only explicit use of
137 ;; beginning-of-defun in CC Mode. Eventually something better
138 ;; than b-o-d will be available and this should be the only
139 ;; place the code needs to change. Everything else should use
140 ;; (goto-char (c-point 'bod))
141 (beginning-of-defun)
142 ;; if defun-prompt-regexp is non-nil, b-o-d won't leave us at
143 ;; the open brace.
144 (and defun-prompt-regexp
145 (looking-at defun-prompt-regexp)
146 (goto-char (match-end 0)))
147 ))
110 (t (error "unknown buffer position requested: %s" position)) 148 (t (error "unknown buffer position requested: %s" position))
111 ) 149 )
112 (prog1 150 (prog1