comparison lisp/progmodes/cc-cmds.el @ 90737:95d0cdf160ea

Merge from emacs--devo--0 Patches applied: * emacs--devo--0 (patch 586-614) - Update from CVS - Update from erc--emacs--22 - Merge from gnus--rel--5.10 - Merge from erc--main--0 - Make byte compiler correctly write circular constants * gnus--rel--5.10 (patch 186-196) - Update from CVS - Merge from emacs--devo--0 Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-162
author Miles Bader <miles@gnu.org>
date Fri, 26 Jan 2007 06:16:11 +0000
parents e4e4a56ef723 9848399916bc
children 52a7f3f50b89
comparison
equal deleted inserted replaced
90736:ef1369583937 90737:95d0cdf160ea
1 ;;; cc-cmds.el --- user level commands for CC Mode 1 ;;; cc-cmds.el --- user level commands for CC Mode
2 2
3 ;; Copyright (C) 1985, 1987, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 3 ;; Copyright (C) 1985, 1987, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
4 ;; 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software 4 ;; 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
5 ;; Foundation, Inc. 5 ;; Free Software Foundation, Inc.
6 6
7 ;; Authors: 1998- Martin Stjernholm 7 ;; Authors: 2003- Alan Mackenzie
8 ;; 1998- Martin Stjernholm
8 ;; 1992-1999 Barry A. Warsaw 9 ;; 1992-1999 Barry A. Warsaw
9 ;; 1987 Dave Detlefs and Stewart Clamen 10 ;; 1987 Dave Detlefs and Stewart Clamen
10 ;; 1985 Richard M. Stallman 11 ;; 1985 Richard M. Stallman
11 ;; Maintainer: bug-cc-mode@gnu.org 12 ;; Maintainer: bug-cc-mode@gnu.org
12 ;; Created: 22-Apr-1997 (split from cc-mode.el) 13 ;; Created: 22-Apr-1997 (split from cc-mode.el)
1380 ;; outwith-function: we're not at or in any function. Being inside a 1381 ;; outwith-function: we're not at or in any function. Being inside a
1381 ;; non-brace construct also counts as 'outwith-function'. 1382 ;; non-brace construct also counts as 'outwith-function'.
1382 ;; 1383 ;;
1383 ;; This function might do hidden buffer changes. 1384 ;; This function might do hidden buffer changes.
1384 (save-excursion 1385 (save-excursion
1385 (let* (pos 1386 (let* (kluge-start
1386 kluge-start
1387 decl-result brace-decl-p 1387 decl-result brace-decl-p
1388 (start (point)) 1388 (start (point))
1389 (paren-state (c-parse-state)) 1389 (paren-state (c-parse-state))
1390 (least-enclosing (c-least-enclosing-brace paren-state))) 1390 (least-enclosing (c-least-enclosing-brace paren-state)))
1391 1391
1414 "\\([;#]\\|\\'\\|\\s(\\|\\s)\\|\\s\"\\|\\s\\\\|\\s$\\|\\s<\\|\\s>\\|\\s!\\)"))) 1414 "\\([;#]\\|\\'\\|\\s(\\|\\s)\\|\\s\"\\|\\s\\\\|\\s$\\|\\s<\\|\\s>\\|\\s!\\)")))
1415 (forward-char)) 1415 (forward-char))
1416 (setq kluge-start (point)) 1416 (setq kluge-start (point))
1417 (setq decl-result 1417 (setq decl-result
1418 (car (c-beginning-of-decl-1 1418 (car (c-beginning-of-decl-1
1419 ;; NOTE: If we're in a K&R region, this might be the start
1420 ;; of a parameter declaration, not the actual function.
1419 (and least-enclosing ; LIMIT for c-b-of-decl-1 1421 (and least-enclosing ; LIMIT for c-b-of-decl-1
1420 (c-safe-position least-enclosing paren-state))))) 1422 (c-safe-position least-enclosing paren-state)))))
1421 1423
1422 ;; Has the declaration we've gone back to got braces? 1424 ;; Has the declaration we've gone back to got braces?
1423 (setq pos (point)) ; the search limit for c-recognize-knr-p
1424 (setq brace-decl-p 1425 (setq brace-decl-p
1425 (save-excursion 1426 (save-excursion
1426 (and (c-syntactic-re-search-forward "[;{]" nil t t) 1427 (and (c-syntactic-re-search-forward "[;{]" nil t t)
1427 (or (eq (char-before) ?\{) 1428 (or (eq (char-before) ?\{)
1428 (and c-recognize-knr-p 1429 (and c-recognize-knr-p
1429 ;; Might have stopped on the 1430 ;; Might have stopped on the
1430 ;; ';' in a K&R argdecl. In 1431 ;; ';' in a K&R argdecl. In
1431 ;; that case the declaration 1432 ;; that case the declaration
1432 ;; should contain a block. 1433 ;; should contain a block.
1433 (c-in-knr-argdecl pos)))))) 1434 (c-in-knr-argdecl))))))
1434 1435
1435 (cond 1436 (cond
1436 ((= (point) kluge-start) ; might be BOB or unbalanced parens. 1437 ((= (point) kluge-start) ; might be BOB or unbalanced parens.
1437 'outwith-function) 1438 'outwith-function)
1438 ((eq decl-result 'same) 1439 ((eq decl-result 'same)
3748 ;; only if the point turns out to be inside a comment or a string. 3749 ;; only if the point turns out to be inside a comment or a string.
3749 ;; 3750 ;;
3750 ;; Note that this function does not do any hidden buffer changes. 3751 ;; Note that this function does not do any hidden buffer changes.
3751 3752
3752 (let (fill 3753 (let (fill
3753 ;; beg and end limits the region to narrow. end is a marker. 3754 ;; beg and end limit the region to narrow. end is a marker.
3754 beg end 3755 beg end
3755 ;; tmp-pre and tmp-post mark strings that are temporarily 3756 ;; tmp-pre and tmp-post mark strings that are temporarily
3756 ;; inserted at the start and end of the region. tmp-pre is a 3757 ;; inserted at the start and end of the region. tmp-pre is a
3757 ;; cons of the positions of the prepended string. tmp-post is 3758 ;; cons of the positions of the prepended string. tmp-post is
3758 ;; a marker pointing to the single character of the appended 3759 ;; a marker pointing to the single character of the appended
3834 (setq tmp-pre t)))) 3835 (setq tmp-pre t))))
3835 3836
3836 (setq apply-outside-literal t)) 3837 (setq apply-outside-literal t))
3837 3838
3838 ((eq c-lit-type 'c) ; Block comment. 3839 ((eq c-lit-type 'c) ; Block comment.
3839 (when (>= end (cdr c-lit-limits)) 3840 (when
3840 ;; The region includes the comment ender. If it's on its own 3841 (or (> end (cdr c-lit-limits))
3841 ;; line, it stays on its own line. If it's got company on the 3842 (and (= end (cdr c-lit-limits))
3842 ;; line, it keeps (at least one word of) it. "=====*/" counts 3843 (eq (char-before end) ?/)
3843 ;; as a comment ender here, but "===== */" doesn't and "foo*/" 3844 (eq (char-before (1- end)) ?*)
3844 ;; doesn't. 3845 ;; disallow "/*/"
3846 (> (- (cdr c-lit-limits) (car c-lit-limits)) 3)))
3847 ;; There is a comment ender, and the region includes it. If
3848 ;; it's on its own line, it stays on its own line. If it's got
3849 ;; company on the line, it keeps (at least one word of) it.
3850 ;; "=====*/" counts as a comment ender here, but "===== */"
3851 ;; doesn't and "foo*/" doesn't.
3845 (unless 3852 (unless
3846 (save-excursion 3853 (save-excursion
3847 (goto-char (cdr c-lit-limits)) 3854 (goto-char (cdr c-lit-limits))
3848 (beginning-of-line) 3855 (beginning-of-line)
3849 (and (search-forward-regexp 3856 (and (search-forward-regexp