comparison lisp/cc-mode/cc-engine.el @ 175:2d532a89d707 r20-3b14

Import from CVS: tag r20-3b14
author cvs
date Mon, 13 Aug 2007 09:50:14 +0200
parents 929b76928fce
children 6075d714658b
comparison
equal deleted inserted replaced
174:bb3568571b84 175:2d532a89d707
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
7 ;; 1985 Richard M. Stallman 7 ;; 1985 Richard M. Stallman
8 ;; Maintainer: cc-mode-help@python.org 8 ;; Maintainer: cc-mode-help@python.org
9 ;; Created: 22-Apr-1997 (split from cc-mode.el) 9 ;; Created: 22-Apr-1997 (split from cc-mode.el)
10 ;; Version: 5.12 10 ;; Version: 5.13
11 ;; Keywords: c languages oop 11 ;; Keywords: c languages oop
12 12
13 ;; This file is part of GNU Emacs. 13 ;; This file is part of GNU Emacs.
14 14
15 ;; GNU Emacs is free software; you can redistribute it and/or modify 15 ;; GNU Emacs is free software; you can redistribute it and/or modify
26 ;; along with GNU Emacs; see the file COPYING. If not, write to the 26 ;; along with GNU Emacs; see the file COPYING. If not, write to the
27 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, 27 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
28 ;; Boston, MA 02111-1307, USA. 28 ;; Boston, MA 02111-1307, USA.
29 29
30 30
31 ;; WARNING: Be *exceptionally* careful about modifications to this 31 ;; KLUDGE ALERT: c-maybe-labelp is used to pass information between
32 ;; function! Much of CC Mode depends on this Doing The Right Thing. 32 ;; c-crosses-statement-barrier-p and c-beginning-of-statement-1. A
33 ;; If you break it you will be sorry. 33 ;; better way should be implemented, but this will at least shut up
34 ;; the byte compiler.
35 (defvar c-maybe-labelp nil)
36
37 ;; WARNING WARNING WARNING
38 ;;
39 ;; Be *exceptionally* careful about modifications to this function!
40 ;; Much of CC Mode depends on this Doing The Right Thing. If you
41 ;; break it you will be sorry. If you think you know how this works,
42 ;; you probably don't. No human on Earth does! :-)
43 ;;
44 ;; WARNING WARNING WARNING
34 45
35 (defun c-beginning-of-statement-1 (&optional lim) 46 (defun c-beginning-of-statement-1 (&optional lim)
36 ;; move to the start of the current statement, or the previous 47 ;; move to the start of the current statement, or the previous
37 ;; statement if already at the beginning of one. 48 ;; statement if already at the beginning of one.
38 (let ((firstp t) 49 (let ((firstp t)
39 (substmt-p t) 50 (substmt-p t)
40 donep c-in-literal-cache 51 donep c-in-literal-cache saved
41 ;; KLUDGE ALERT: maybe-labelp is used to pass information
42 ;; between c-crosses-statement-barrier-p and
43 ;; c-beginning-of-statement-1. A better way should be
44 ;; implemented.
45 maybe-labelp saved
46 (last-begin (point))) 52 (last-begin (point)))
47 ;; first check for bare semicolon 53 ;; first check for bare semicolon
48 (if (and (progn (c-backward-syntactic-ws lim) 54 (if (and (progn (c-backward-syntactic-ws lim)
49 (eq (char-before) ?\;)) 55 (eq (char-before) ?\;))
50 (c-safe (progn (forward-char -1) 56 (c-safe (progn (forward-char -1)
74 (setq last-begin (point)))) 80 (setq last-begin (point))))
75 (goto-char last-begin) 81 (goto-char last-begin)
76 (setq last-begin (point) 82 (setq last-begin (point)
77 donep t))) 83 donep t)))
78 84
79 (setq maybe-labelp nil) 85 (setq c-maybe-labelp nil)
80 ;; see if we're in a literal. if not, then this bufpos may be 86 ;; see if we're in a literal. if not, then this bufpos may be
81 ;; a candidate for stopping 87 ;; a candidate for stopping
82 (cond 88 (cond
83 ;; CASE 0: did we hit the error condition above? 89 ;; CASE 0: did we hit the error condition above?
84 (donep) 90 (donep)
136 last-begin (point))) 142 last-begin (point)))
137 ;; CASE 6: have we crossed a statement barrier? 143 ;; CASE 6: have we crossed a statement barrier?
138 ((c-crosses-statement-barrier-p (point) last-begin) 144 ((c-crosses-statement-barrier-p (point) last-begin)
139 (setq donep t)) 145 (setq donep t))
140 ;; CASE 7: ignore labels 146 ;; CASE 7: ignore labels
141 ((and maybe-labelp 147 ((and c-maybe-labelp
142 (or (and c-access-key (looking-at c-access-key)) 148 (or (and c-access-key (looking-at c-access-key))
143 ;; with switch labels, we have to go back further 149 ;; with switch labels, we have to go back further
144 ;; to try to pick up the case or default 150 ;; to try to pick up the case or default
145 ;; keyword. Potential bogosity alert: we assume 151 ;; keyword. Potential bogosity alert: we assume
146 ;; `case' or `default' is first thing on line 152 ;; `case' or `default' is first thing on line
199 (if (not (c-in-literal lim)) 205 (if (not (c-in-literal lim))
200 (progn 206 (progn
201 (if (memq (char-after) '(?\; ?{ ?})) 207 (if (memq (char-after) '(?\; ?{ ?}))
202 (setq crossedp t) 208 (setq crossedp t)
203 (if (eq (char-after) ?:) 209 (if (eq (char-after) ?:)
204 (setq maybe-labelp t)) 210 (setq c-maybe-labelp t))
205 (forward-char 1)) 211 (forward-char 1))
206 (setq lim (point))) 212 (setq lim (point)))
207 (forward-char 1)))) 213 (forward-char 1))))
208 (error (setq crossedp nil))) 214 (error (setq crossedp nil)))
209 (goto-char here) 215 (goto-char here)