Mercurial > emacs
comparison lisp/progmodes/cc-engine.el @ 91015:b83d0dadb2a7
Merge from emacs--devo--0
Patches applied:
* emacs--devo--0 (patch 857-865)
- Update from CVS
- Merge from emacs--rel--22
- Update from CVS: lisp/emacs-lisp/avl-tree.el: New file.
- Remove RCS keywords
* emacs--rel--22 (patch 97-100)
- Update from CVS
- Merge from gnus--rel--5.10
* gnus--rel--5.10 (patch 246-247)
- Update from CVS
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-252
author | Miles Bader <miles@gnu.org> |
---|---|
date | Wed, 29 Aug 2007 05:03:40 +0000 |
parents | 424b655804ca b3cad8795b91 |
children | 4bc33ffdda1a |
comparison
equal
deleted
inserted
replaced
91014:2392e6a45952 | 91015:b83d0dadb2a7 |
---|---|
4065 (if c-maybe-stale-found-type ; e.g. (c-decl-id-start "foo" 97 107 " (* ooka) " "o") | 4065 (if c-maybe-stale-found-type ; e.g. (c-decl-id-start "foo" 97 107 " (* ooka) " "o") |
4066 (cond | 4066 (cond |
4067 ;; Changing the amount of (already existing) whitespace - don't do anything. | 4067 ;; Changing the amount of (already existing) whitespace - don't do anything. |
4068 ((and (c-partial-ws-p beg end) | 4068 ((and (c-partial-ws-p beg end) |
4069 (or (= beg end) ; removal of WS | 4069 (or (= beg end) ; removal of WS |
4070 ; (string-match "\\s *\\'" (nth 5 c-maybe-stale-found-type)) | |
4071 (string-match "^[ \t\n\r\f\v]*$" (nth 5 c-maybe-stale-found-type))))) | 4070 (string-match "^[ \t\n\r\f\v]*$" (nth 5 c-maybe-stale-found-type))))) |
4072 | 4071 |
4073 ;; The syntactic relationship which defined a "found type" has been | 4072 ;; The syntactic relationship which defined a "found type" has been |
4074 ;; destroyed. | 4073 ;; destroyed. |
4075 ((eq (car c-maybe-stale-found-type) 'c-decl-id-start) | 4074 ((eq (car c-maybe-stale-found-type) 'c-decl-id-start) |
5889 ;; return t; | 5888 ;; return t; |
5890 ;; (iv) One of QT's "extended" C++ variants of | 5889 ;; (iv) One of QT's "extended" C++ variants of |
5891 ;; "private:"/"protected:"/"public:"/"more:" looking like "public slots:". | 5890 ;; "private:"/"protected:"/"public:"/"more:" looking like "public slots:". |
5892 ;; Returns the symbol `qt-2kwds-colon'. | 5891 ;; Returns the symbol `qt-2kwds-colon'. |
5893 ;; (v) QT's construct "signals:". Returns the symbol `qt-1kwd-colon'. | 5892 ;; (v) QT's construct "signals:". Returns the symbol `qt-1kwd-colon'. |
5894 ;; (v) One of the keywords matched by `c-opt-extra-label-key' (without any | 5893 ;; (vi) One of the keywords matched by `c-opt-extra-label-key' (without any |
5895 ;; colon). Currently (2006-03), this applies only to Objective C's | 5894 ;; colon). Currently (2006-03), this applies only to Objective C's |
5896 ;; keywords "@private", "@protected", and "@public". Returns t. | 5895 ;; keywords "@private", "@protected", and "@public". Returns t. |
5897 ;; | 5896 ;; |
5898 ;; One of the things which will NOT be recognised as a label is a bit-field | 5897 ;; One of the things which will NOT be recognised as a label is a bit-field |
5899 ;; element of a struct, something like "int foo:5". | 5898 ;; element of a struct, something like "int foo:5". |
6115 (while (c-syntactic-re-search-forward c-symbol-key nil t) | 6114 (while (c-syntactic-re-search-forward c-symbol-key nil t) |
6116 (c-record-ref-id (cons (match-beginning 0) | 6115 (c-record-ref-id (cons (match-beginning 0) |
6117 (match-end 0))))) | 6116 (match-end 0))))) |
6118 | 6117 |
6119 (c-put-c-type-property (1- (point-max)) 'c-decl-end) | 6118 (c-put-c-type-property (1- (point-max)) 'c-decl-end) |
6120 (goto-char (point-max)) | 6119 (goto-char (point-max))))) |
6121 ))) | |
6122 | 6120 |
6123 (t | 6121 (t |
6124 ;; Not a label. | 6122 ;; Not a label. |
6125 (goto-char start))) | 6123 (goto-char start))) |
6126 label-type)) | 6124 label-type)) |
7195 | 7193 |
7196 ;; Dynamically bound to t when `c-guess-basic-syntax' is called during | 7194 ;; Dynamically bound to t when `c-guess-basic-syntax' is called during |
7197 ;; auto newline analysis. | 7195 ;; auto newline analysis. |
7198 (defvar c-auto-newline-analysis nil) | 7196 (defvar c-auto-newline-analysis nil) |
7199 | 7197 |
7198 (defun c-brace-anchor-point (bracepos) | |
7199 ;; BRACEPOS is the position of a brace in a construct like "namespace | |
7200 ;; Bar {". Return the anchor point in this construct; this is the | |
7201 ;; earliest symbol on the brace's line which isn't earlier than | |
7202 ;; "namespace". | |
7203 ;; | |
7204 ;; Currently (2007-08-17), "like namespace" means "matches | |
7205 ;; c-other-block-decl-kwds". It doesn't work with "class" or "struct" | |
7206 ;; or anything like that. | |
7207 (save-excursion | |
7208 (let ((boi (c-point 'boi bracepos))) | |
7209 (goto-char bracepos) | |
7210 (while (and (> (point) boi) | |
7211 (not (looking-at c-other-decl-block-key))) | |
7212 (c-backward-token-2)) | |
7213 (if (> (point) boi) (point) boi)))) | |
7214 | |
7200 (defsubst c-add-syntax (symbol &rest args) | 7215 (defsubst c-add-syntax (symbol &rest args) |
7201 ;; A simple function to prepend a new syntax element to | 7216 ;; A simple function to prepend a new syntax element to |
7202 ;; `c-syntactic-context'. Using `setq' on it is unsafe since it | 7217 ;; `c-syntactic-context'. Using `setq' on it is unsafe since it |
7203 ;; should always be dynamically bound but since we read it first | 7218 ;; should always be dynamically bound but since we read it first |
7204 ;; we'll fail properly anyway if this function is misused. | 7219 ;; we'll fail properly anyway if this function is misused. |
7227 ;; find a statement or block start that begins at boi without a | 7242 ;; find a statement or block start that begins at boi without a |
7228 ;; label or comment. | 7243 ;; label or comment. |
7229 ;; | 7244 ;; |
7230 ;; Point is assumed to be at the prospective anchor point for the | 7245 ;; Point is assumed to be at the prospective anchor point for the |
7231 ;; given SYNTAX-SYMBOL. More syntax entries are added if we need to | 7246 ;; given SYNTAX-SYMBOL. More syntax entries are added if we need to |
7232 ;; skip past open parens and containing statements. All the added | 7247 ;; skip past open parens and containing statements. Most of the added |
7233 ;; syntax elements will get the same anchor point. | 7248 ;; syntax elements will get the same anchor point - the exception is |
7249 ;; for an anchor in a construct like "namespace"[*] - this is as early | |
7250 ;; as possible in the construct but on the same line as the {. | |
7251 ;; | |
7252 ;; [*] i.e. with a keyword matching c-other-block-decl-kwds. | |
7234 ;; | 7253 ;; |
7235 ;; SYNTAX-EXTRA-ARGS are a list of the extra arguments for the | 7254 ;; SYNTAX-EXTRA-ARGS are a list of the extra arguments for the |
7236 ;; syntax symbol. They are appended after the anchor point. | 7255 ;; syntax symbol. They are appended after the anchor point. |
7237 ;; | 7256 ;; |
7238 ;; If STOP-AT-BOI-ONLY is nil, we can stop in the middle of the line | 7257 ;; If STOP-AT-BOI-ONLY is nil, we can stop in the middle of the line |
7253 ;; Set when we're on a label, so that we don't stop there. | 7272 ;; Set when we're on a label, so that we don't stop there. |
7254 ;; FIXME: To be complete we should check if we're on a label | 7273 ;; FIXME: To be complete we should check if we're on a label |
7255 ;; now at the start. | 7274 ;; now at the start. |
7256 on-label) | 7275 on-label) |
7257 | 7276 |
7258 (apply 'c-add-syntax syntax-symbol nil syntax-extra-args) | 7277 ;; Use point as the anchor point for "namespace", "extern", etc. |
7278 (apply 'c-add-syntax syntax-symbol | |
7279 (if (rassq syntax-symbol c-other-decl-block-key-in-symbols-alist) | |
7280 (point) nil) | |
7281 syntax-extra-args) | |
7259 | 7282 |
7260 ;; Loop while we have to back out of containing blocks. | 7283 ;; Loop while we have to back out of containing blocks. |
7261 (while | 7284 (while |
7262 (and | 7285 (and |
7263 (catch 'back-up-block | 7286 (catch 'back-up-block |
7373 (1+ containing-sexp) | 7396 (1+ containing-sexp) |
7374 (point-min)))) | 7397 (point-min)))) |
7375 (setq step-type 'same | 7398 (setq step-type 'same |
7376 on-label nil)) | 7399 on-label nil)) |
7377 | 7400 |
7401 ;; Stepped out of a brace block. | |
7378 (setq step-type (c-beginning-of-statement-1 containing-sexp) | 7402 (setq step-type (c-beginning-of-statement-1 containing-sexp) |
7379 on-label (eq step-type 'label)) | 7403 on-label (eq step-type 'label)) |
7380 | 7404 |
7381 (if (and (eq step-type 'same) | 7405 (if (and (eq step-type 'same) |
7382 (/= paren-pos (point))) | 7406 (/= paren-pos (point))) |
7383 (save-excursion | 7407 (let (inexpr) |
7384 (goto-char paren-pos) | 7408 (cond |
7385 (let ((inexpr (c-looking-at-inexpr-block | 7409 ((save-excursion |
7386 (c-safe-position containing-sexp | 7410 (goto-char paren-pos) |
7387 paren-state) | 7411 (setq inexpr (c-looking-at-inexpr-block |
7388 containing-sexp))) | 7412 (c-safe-position containing-sexp paren-state) |
7389 (if (and inexpr | 7413 containing-sexp))) |
7390 (not (eq (car inexpr) 'inlambda))) | 7414 (c-add-syntax (if (eq (car inexpr) 'inlambda) |
7391 (c-add-syntax 'statement-block-intro nil) | 7415 'defun-block-intro |
7392 (c-add-syntax 'defun-block-intro nil)))) | 7416 'statement-block-intro) |
7393 (c-add-syntax 'statement-block-intro nil))) | 7417 nil)) |
7418 ((looking-at c-other-decl-block-key) | |
7419 (c-add-syntax | |
7420 (cdr (assoc (match-string 1) | |
7421 c-other-decl-block-key-in-symbols-alist)) | |
7422 (max (c-point 'boi paren-pos) (point)))) | |
7423 (t (c-add-syntax 'defun-block-intro nil)))) | |
7424 | |
7425 (c-add-syntax 'statement-block-intro nil))) | |
7394 | 7426 |
7395 (if (= paren-pos boi) | 7427 (if (= paren-pos boi) |
7396 ;; Always done if the open brace was at boi. The | 7428 ;; Always done if the open brace was at boi. The |
7397 ;; c-beginning-of-statement-1 call above is necessary | 7429 ;; c-beginning-of-statement-1 call above is necessary |
7398 ;; anyway, to decide the type of block-intro to add. | 7430 ;; anyway, to decide the type of block-intro to add. |
7400 (setq boi (c-point 'boi))) | 7432 (setq boi (c-point 'boi))) |
7401 )) | 7433 )) |
7402 | 7434 |
7403 ;; Fill in the current point as the anchor for all the symbols | 7435 ;; Fill in the current point as the anchor for all the symbols |
7404 ;; added above. | 7436 ;; added above. |
7405 (let ((p c-syntactic-context)) | 7437 (let ((p c-syntactic-context) q) |
7406 (while (not (eq p syntax-last)) | 7438 (while (not (eq p syntax-last)) |
7407 (if (cdr (car p)) | 7439 (setq q (cdr (car p))) ; e.g. (nil 28) [from (arglist-cont-nonempty nil 28)] |
7408 (setcar (cdr (car p)) (point))) | 7440 (while q |
7441 (unless (car q) | |
7442 (setcar q (point))) | |
7443 (setq q (cdr q))) | |
7409 (setq p (cdr p)))) | 7444 (setq p (cdr p)))) |
7410 ))) | 7445 ))) |
7411 | 7446 |
7412 (defun c-add-class-syntax (symbol | 7447 (defun c-add-class-syntax (symbol |
7413 containing-decl-open | 7448 containing-decl-open |
8358 (c-add-syntax 'topmost-intro (c-point 'bol)) | 8393 (c-add-syntax 'topmost-intro (c-point 'bol)) |
8359 (if containing-decl-open | 8394 (if containing-decl-open |
8360 (if (c-keyword-member containing-decl-kwd | 8395 (if (c-keyword-member containing-decl-kwd |
8361 'c-other-block-decl-kwds) | 8396 'c-other-block-decl-kwds) |
8362 (progn | 8397 (progn |
8363 (goto-char containing-decl-open) | 8398 (goto-char (c-brace-anchor-point containing-decl-open)) |
8364 (unless (= (point) (c-point 'boi)) | |
8365 (goto-char containing-decl-start)) | |
8366 (c-add-stmt-syntax | 8399 (c-add-stmt-syntax |
8367 (if (string-equal (symbol-name containing-decl-kwd) | 8400 (if (string-equal (symbol-name containing-decl-kwd) |
8368 "extern") | 8401 "extern") |
8369 ;; Special case for compatibility with the | 8402 ;; Special case for compatibility with the |
8370 ;; extern-lang syntactic symbols. | 8403 ;; extern-lang syntactic symbols. |