Mercurial > emacs
annotate lisp/obsolete/cplus-md.el @ 45835:aab759361c24
(Fset_window_configuration): Explicitly preserve
the point value that new_current_buffer had at the start.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sat, 15 Jun 2002 14:20:52 +0000 |
parents | 7308bbc423d5 |
children | 6bbd5bfd790f |
rev | line source |
---|---|
36927
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1 ;;; cplus-md.el --- old C++ code editing mode for Emacs |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
2 |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
3 ;; Copyright (C) 1985, 1992, 1994, 1995 Free Software Foundation, Inc. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
4 |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
5 ;; Maintainer: FSF |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
6 ;; Keywords: c |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
7 |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
8 ;; This file is part of GNU Emacs. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
9 |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
10 ;; GNU Emacs is free software; you can redistribute it and/or modify |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
11 ;; it under the terms of the GNU General Public License as published by |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
12 ;; the Free Software Foundation; either version 2, or (at your option) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
13 ;; any later version. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
14 |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
15 ;; GNU Emacs is distributed in the hope that it will be useful, |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
18 ;; GNU General Public License for more details. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
19 |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
20 ;; You should have received a copy of the GNU General Public License |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
23 ;; Boston, MA 02111-1307, USA. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
24 |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
25 ;;; Commentary: |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
26 |
41609 | 27 ;; 1987 Dave Detlefs <dld@cs.cmu.edu> |
36927
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
28 ;; and Stewart Clamen <clamen@cs.cmu.edu>. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
29 ;; Done by fairly faithful modification of: |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
30 |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
31 ;;; Change Log: |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
32 |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
33 ;; Feb, 1990 (Dave Detlefs, dld@cs.cmu.edu) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
34 ;; Fixed electric-c++-terminator to handle double colons, at the |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
35 ;; request of John Hagerman. |
41609 | 36 ;; |
36927
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
37 ;; Jan, 1990 (Doug Lea, dl@oswego.edu) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
38 ;; Replaced c++-comment-region and c++-uncomment-region with |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
39 ;; versions from Igor Metz that avoid potential infinite loops. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
40 ;; |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
41 ;; Oct, 1989 (Dave Detlefs, dld@cs.cmu.edu) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
42 ;; Added contribution from Igor Metz <metz@iam.unibe.ch>: |
41609 | 43 ;; functions c++-comment-region and c++-uncomment-region and |
36927
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
44 ;; corresponding key-binding. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
45 ;; Also fixed bug in indentation of second line after an empty |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
46 ;; arglist with empty-arglist non-null. |
41609 | 47 ;; |
36927
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
48 ;; Sept, 1989 (Glen Ditchfield, gjditchfield@violet.uwaterloo.ca): |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
49 ;; Textual changes to more closely imitate Emacs 18.55's c-mode. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
50 ;; Fixed handling of "default:", where ":" was the last character in the |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
51 ;; buffer. Fixed indentation of comments starting in column 0, and when |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
52 ;; previous line contained more than one comment start string. Fixed |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
53 ;; handling of "friend". |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
54 ;; |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
55 ;; Aug 7, 1989; John Hagerman (hagerman@ece.cmu.edu): |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
56 ;; Changed calculate-c++-indent to handle member initializations |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
57 ;; more flexibly. Two new variables are used to control behavior: |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
58 ;; c++-member-init-indent and c++-continued-member-init-offset. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
59 ;; Note the assumption that member initializations and argument |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
60 ;; declarations are not mixed in one function definition. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
61 ;; |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
62 ;; June 1989 (Dave Detlefs, dld@cs.cmu.edu) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
63 ;; Fixed calculate-c++-indent to handle continued lines ending in |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
64 ;; {'s. (I wasn't following C-mode closely enough, or C-mode |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
65 ;; changed.) Made ' a quote character, at the behest of someone |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
66 ;; whose mail I apparently deleted (if they send me mail I'll credit |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
67 ;; them here in a future revision.) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
68 ;; Dan Weinreb (dlw@odi.com) pointed out that 'c++-mode successively |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
69 ;; bound c++-indent-exp and c++-indent-defun to ESC-^q. ESC-^q is |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
70 ;; now bound to c++-indent-exp, while, c++-indent-defun is invoked |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
71 ;; with ESC-^x. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
72 |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
73 ;; February 1989 (Dave Detlefs, dld@cs.cmu.edu) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
74 ;; Fixed some errors in c++-indent-defun, as pointed out by Sam |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
75 ;; Haradhvala (odi!sam@talcott.harvard.edu). |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
76 ;; October 1988 (Dave Detlefs, dld@cs.cmu.edu) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
77 ;; It turns out I had only *thought* I had made |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
78 ;; beginning(end)-of-defun work. It should work better now -- you |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
79 ;; can either attempt to match defun headers "strongly," using a |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
80 ;; very complicated regexp, or "weakly," using a simple one. This |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
81 ;; is settable by a variable; the default is the cheaper weak |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
82 ;; method. (Stewart Clamen was intimately involved in this, too.) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
83 ;; |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
84 ;; I made "'" *not* be a string delimiter, because that was causing |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
85 ;; comments containing contractions to ("// don't") to mess up paren |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
86 ;; balancing. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
87 ;; |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
88 ;; I also incorporated another slight indentation fix from Glen |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
89 ;; Ditchfield. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
90 ;; |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
91 ;; We hope this is will make into version 19 of gnu-emacs. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
92 ;; |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
93 ;; September 1988: incorporated changes from Fred Calm at Schlumberger. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
94 ;; Also, made beginning(end)-of-defun, indent-defun work. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
95 ;; |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
96 ;; August 1987: incorporated changes done by Glen Ditchfield of Waterloo. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
97 |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
98 ;;; Code: |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
99 |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
100 (defgroup old-c++ nil |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
101 "Old C++ code editing mode for Emacs." |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
102 ;; This group should have no parent. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
103 ;; We don't want it to be loaded except on explicit request. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
104 :prefix "c-") |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
105 |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
106 (defvar c++-mode-abbrev-table nil |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
107 "Abbrev table used in C++ mode.") |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
108 (define-abbrev-table 'c++-mode-abbrev-table ()) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
109 |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
110 (defvar c++-mode-map () |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
111 "Keymap used in C++ mode.") |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
112 (if c++-mode-map |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
113 () |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
114 (setq c++-mode-map (make-sparse-keymap)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
115 (define-key c++-mode-map "\C-j" 'reindent-then-newline-and-indent) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
116 (define-key c++-mode-map "{" 'electric-c++-brace) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
117 (define-key c++-mode-map "}" 'electric-c++-brace) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
118 (define-key c++-mode-map ";" 'electric-c++-semi) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
119 (define-key c++-mode-map "\e\C-h" 'mark-c-function) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
120 (define-key c++-mode-map "\e\C-q" 'indent-c++-exp) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
121 (define-key c++-mode-map "\177" 'backward-delete-char-untabify) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
122 (define-key c++-mode-map "\t" 'c++-indent-command) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
123 ;; (define-key c++-mode-map "\C-c\C-i" 'c++-insert-header) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
124 (define-key c++-mode-map "\C-c\C-\\" 'c-backslash-region)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
125 ;; (define-key c++-mode-map "\e\C-a" 'c++-beginning-of-defun) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
126 ;; (define-key c++-mode-map "\e\C-e" 'c++-end-of-defun) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
127 ;; (define-key c++-mode-map "\e\C-x" 'c++-indent-defun)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
128 |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
129 (defvar c++-mode-syntax-table nil |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
130 "Syntax table used in C++ mode.") |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
131 |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
132 (if c++-mode-syntax-table |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
133 () |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
134 (setq c++-mode-syntax-table (make-syntax-table)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
135 (modify-syntax-entry ?\\ "\\" c++-mode-syntax-table) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
136 (modify-syntax-entry ?/ ". 14" c++-mode-syntax-table) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
137 (modify-syntax-entry ?* ". 23" c++-mode-syntax-table) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
138 (modify-syntax-entry ?+ "." c++-mode-syntax-table) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
139 (modify-syntax-entry ?- "." c++-mode-syntax-table) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
140 (modify-syntax-entry ?= "." c++-mode-syntax-table) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
141 (modify-syntax-entry ?% "." c++-mode-syntax-table) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
142 (modify-syntax-entry ?< "." c++-mode-syntax-table) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
143 (modify-syntax-entry ?> "." c++-mode-syntax-table) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
144 (modify-syntax-entry ?& "." c++-mode-syntax-table) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
145 (modify-syntax-entry ?| "." c++-mode-syntax-table) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
146 (modify-syntax-entry ?\' "\"" c++-mode-syntax-table) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
147 (modify-syntax-entry ?* ". 23b" c++-mode-syntax-table) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
148 (modify-syntax-entry ?/ ". 124" c++-mode-syntax-table) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
149 (modify-syntax-entry ?\n ">" c++-mode-syntax-table) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
150 (modify-syntax-entry ?\^m ">" c++-mode-syntax-table)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
151 |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
152 (defcustom c++-continued-member-init-offset nil |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
153 "*Extra indent for continuation lines of member inits; |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
154 nil means to align with previous initializations rather than |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
155 with the colon on the first line." |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
156 :type '(choice (const nil) integer) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
157 :group 'old-c++) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
158 (defcustom c++-member-init-indent 0 |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
159 "*Indentation level of member initializations in function declarations." |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
160 :type 'integer |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
161 :group 'old-c++) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
162 (defcustom c++-friend-offset -4 |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
163 "*Offset of C++ friend declarations relative to member declarations." |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
164 :type 'integer |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
165 :group 'old-c++) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
166 (defcustom c++-electric-colon t |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
167 "*If t, colon is an electric terminator." |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
168 :type 'boolean |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
169 :group 'old-c++) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
170 (defcustom c++-empty-arglist-indent nil |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
171 "*Indicates how far to indent an line following an empty argument |
42205 | 172 list. nil indicates to just after the paren." |
36927
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
173 :type '(choice (const nil) integer) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
174 :group 'old-c++) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
175 |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
176 (defvar c++-imenu-generic-expression |
41608
45db352a0971
Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents:
41569
diff
changeset
|
177 `((nil |
45db352a0971
Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents:
41569
diff
changeset
|
178 ,(concat |
45db352a0971
Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents:
41569
diff
changeset
|
179 "^" ; beginning of line is required |
36927
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
180 "\\(template[ \t]*<[^>]+>[ \t]*\\)?" ; there may be a "template <...>" |
41608
45db352a0971
Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents:
41569
diff
changeset
|
181 "\\([a-zA-Z0-9_:]+[ \t]+\\)?" ; type specs; there can be no |
45db352a0971
Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents:
41569
diff
changeset
|
182 "\\([a-zA-Z0-9_:]+[ \t]+\\)?" ; more than 3 tokens, right? |
41609 | 183 |
41608
45db352a0971
Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents:
41569
diff
changeset
|
184 "\\(" ; last type spec including */& |
36927
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
185 "[a-zA-Z0-9_:]+" |
41608
45db352a0971
Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents:
41569
diff
changeset
|
186 "\\([ \t]*[*&]+[ \t]*\\|[ \t]+\\)" ; either pointer/ref sign or whitespace |
45db352a0971
Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents:
41569
diff
changeset
|
187 "\\)?" ; if there is a last type spec |
45db352a0971
Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents:
41569
diff
changeset
|
188 "\\(" ; name; take that into the imenu entry |
45db352a0971
Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents:
41569
diff
changeset
|
189 "[a-zA-Z0-9_:~]+" ; member function, ctor or dtor... |
41609 | 190 ; (may not contain * because then |
41608
45db352a0971
Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents:
41569
diff
changeset
|
191 ; "a::operator char*" would become "char*"!) |
36927
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
192 "\\|" |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
193 "\\([a-zA-Z0-9_:~]*::\\)?operator" |
41608
45db352a0971
Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents:
41569
diff
changeset
|
194 "[^a-zA-Z1-9_][^(]*" ; ...or operator |
36927
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
195 " \\)" |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
196 "[ \t]*([^)]*)[ \t\n]*[^ ;]" ; require something other than a ; after |
41608
45db352a0971
Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents:
41569
diff
changeset
|
197 ; the (...) to avoid prototypes. Can't |
45db352a0971
Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents:
41569
diff
changeset
|
198 ; catch cases with () inside the parentheses |
45db352a0971
Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents:
41569
diff
changeset
|
199 ; surrounding the parameters |
45db352a0971
Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents:
41569
diff
changeset
|
200 ; (like "int foo(int a=bar()) {...}" |
41609 | 201 |
202 ) 6) | |
203 ("Class" | |
204 ,(concat | |
41608
45db352a0971
Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents:
41569
diff
changeset
|
205 "^" ; beginning of line is required |
45db352a0971
Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents:
41569
diff
changeset
|
206 "\\(template[ \t]*<[^>]+>[ \t]*\\)?" ; there may be a "template <...>" |
45db352a0971
Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents:
41569
diff
changeset
|
207 "class[ \t]+" |
45db352a0971
Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents:
41569
diff
changeset
|
208 "\\([a-zA-Z0-9_]+\\)" ; this is the string we want to get |
45db352a0971
Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents:
41569
diff
changeset
|
209 "[ \t]*[:{]" |
45db352a0971
Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents:
41569
diff
changeset
|
210 ) 2) |
45db352a0971
Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents:
41569
diff
changeset
|
211 ;; Example of generic expression for finding prototypes, structs, unions, enums. |
45db352a0971
Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents:
41569
diff
changeset
|
212 ;; Uncomment if you want to find these too. It will be a bit slower gathering |
45db352a0971
Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents:
41569
diff
changeset
|
213 ;; the indexes. |
41652 | 214 ;;; ("Prototypes" |
215 ;;; (, | |
216 ;;; (concat | |
217 ;;; "^" ; beginning of line is required | |
218 ;;; "\\(template[ \t]*<[^>]+>[ \t]*\\)?" ; there may be a "template <...>" | |
219 ;;; "\\([a-zA-Z0-9_:]+[ \t]+\\)?" ; type specs; there can be no | |
220 ;;; "\\([a-zA-Z0-9_:]+[ \t]+\\)?" ; more than 3 tokens, right? | |
41609 | 221 |
41652 | 222 ;;; "\\(" ; last type spec including */& |
223 ;;; "[a-zA-Z0-9_:]+" | |
224 ;;; "\\([ \t]*[*&]+[ \t]*\\|[ \t]+\\)" ; either pointer/ref sign or whitespace | |
225 ;;; "\\)?" ; if there is a last type spec | |
226 ;;; "\\(" ; name; take that into the imenu entry | |
227 ;;; "[a-zA-Z0-9_:~]+" ; member function, ctor or dtor... | |
228 ;;; ; (may not contain * because then | |
229 ;;; ; "a::operator char*" would become "char*"!) | |
230 ;;; "\\|" | |
231 ;;; "\\([a-zA-Z0-9_:~]*::\\)?operator" | |
232 ;;; "[^a-zA-Z1-9_][^(]*" ; ...or operator | |
233 ;;; " \\)" | |
234 ;;; "[ \t]*([^)]*)[ \t\n]*;" ; require ';' after | |
235 ;;; ; the (...) Can't | |
236 ;;; ; catch cases with () inside the parentheses | |
237 ;;; ; surrounding the parameters | |
238 ;;; ; (like "int foo(int a=bar());" | |
239 ;;; )) 6) | |
240 ;;; ("Struct" | |
241 ;;; (, (concat | |
242 ;;; "^" ; beginning of line is required | |
243 ;;; "\\(static[ \t]+\\)?" ; there may be static or const. | |
244 ;;; "\\(const[ \t]+\\)?" | |
245 ;;; "struct[ \t]+" | |
246 ;;; "\\([a-zA-Z0-9_]+\\)" ; this is the string we want to get | |
247 ;;; "[ \t]*[{]" | |
248 ;;; )) 3) | |
249 ;;; ("Enum" | |
250 ;;; (, (concat | |
251 ;;; "^" ; beginning of line is required | |
252 ;;; "\\(static[ \t]+\\)?" ; there may be static or const. | |
253 ;;; "\\(const[ \t]+\\)?" | |
254 ;;; "enum[ \t]+" | |
255 ;;; "\\([a-zA-Z0-9_]+\\)" ; this is the string we want to get | |
256 ;;; "[ \t]*[{]" | |
257 ;;; )) 3) | |
258 ;;; ("Union" | |
259 ;;; (, (concat | |
260 ;;; "^" ; beginning of line is required | |
261 ;;; "\\(static[ \t]+\\)?" ; there may be static or const. | |
262 ;;; "\\(const[ \t]+\\)?" | |
263 ;;; "union[ \t]+" | |
264 ;;; "\\([a-zA-Z0-9_]+\\)" ; this is the string we want to get | |
265 ;;; "[ \t]*[{]" | |
266 ;;; )) 3) | |
41608
45db352a0971
Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents:
41569
diff
changeset
|
267 ) |
36927
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
268 "Imenu generic expression for C++ mode. See `imenu-generic-expression'.") |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
269 |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
270 (defun c++-mode () |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
271 "Major mode for editing C++ code. Very much like editing C code. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
272 Expression and list commands understand all C++ brackets. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
273 Tab at left margin indents for C++ code |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
274 Comments are delimited with /* ... */ {or with // ... <newline>} |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
275 Paragraphs are separated by blank lines only. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
276 Delete converts tabs to spaces as it moves back. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
277 \\{c++-mode-map} |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
278 Variables controlling indentation style: |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
279 c-tab-always-indent |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
280 Non-nil means TAB in C mode should always reindent the current line, |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
281 regardless of where in the line point is when the TAB command is used. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
282 Default is t. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
283 c-auto-newline |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
284 Non-nil means automatically newline before and after braces, |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
285 and after colons and semicolons, inserted in C code. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
286 c-indent-level |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
287 Indentation of C statements within surrounding block. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
288 The surrounding block's indentation is the indentation |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
289 of the line on which the open-brace appears. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
290 c-continued-statement-offset |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
291 Extra indentation given to a substatement, such as the |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
292 then-clause of an if or body of a while. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
293 c-continued-brace-offset |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
294 Extra indentation given to a brace that starts a substatement. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
295 This is in addition to c-continued-statement-offset. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
296 c-brace-offset |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
297 Extra indentation for line if it starts with an open brace. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
298 c-brace-imaginary-offset |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
299 An open brace following other text is treated as if it were |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
300 this far to the right of the start of its line. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
301 c-argdecl-indent |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
302 Indentation level of declarations of C function arguments. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
303 c-label-offset |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
304 Extra indentation for line that is a label, or case or ``default:'', or |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
305 ``public:'' or ``private:'', or ``protected:''. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
306 c++-electric-colon |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
307 If non-nil at invocation of c++-mode (t is the default) colon electrically |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
308 indents. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
309 c++-empty-arglist-indent |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
310 If non-nil, a function declaration or invocation which ends a line with a |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
311 left paren is indented this many extra spaces, instead of flush with the |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
312 left paren. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
313 c++-friend-offset |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
314 Offset of C++ friend declarations relative to member declarations. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
315 c++-member-init-indent |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
316 Indentation level of member initializations in function declarations, |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
317 if they are on a separate line beginning with a colon. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
318 c++-continued-member-init-offset |
42205 | 319 Extra indentation for continuation lines of member initializations; nil |
36927
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
320 means to align with previous initializations rather than with the colon. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
321 |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
322 Settings for K&R, BSD, and Stroustrup indentation styles are |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
323 c-indent-level 5 8 4 |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
324 c-continued-statement-offset 5 8 4 |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
325 c-continued-brace-offset 0 |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
326 c-brace-offset -5 -8 0 |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
327 c-brace-imaginary-offset 0 |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
328 c-argdecl-indent 0 8 4 |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
329 c-label-offset -5 -8 -4 |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
330 c++-empty-arglist-indent 4 |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
331 c++-friend-offset 0 |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
332 |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
333 Turning on C++ mode calls the value of the variable `c++-mode-hook' with |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
334 no args if that value is non-nil." |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
335 (interactive) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
336 (kill-all-local-variables) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
337 ;; This code depends on the old C mode. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
338 (require 'c-mode) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
339 (use-local-map c++-mode-map) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
340 (set-syntax-table c++-mode-syntax-table) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
341 (setq major-mode 'c++-mode |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
342 mode-name "C++" |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
343 comment-column 32 |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
344 local-abbrev-table c++-mode-abbrev-table) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
345 (set (make-local-variable 'indent-line-function) 'c++-indent-line) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
346 (set (make-local-variable 'comment-start) "// ") |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
347 (set (make-local-variable 'comment-end) "") |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
348 (set (make-local-variable 'comment-start-skip) "/\\*+ *\\|// *") |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
349 (set (make-local-variable 'comment-indent-function) 'c++-comment-indent) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
350 (set (make-local-variable 'paragraph-start) (concat "$\\|" page-delimiter)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
351 (set (make-local-variable 'paragraph-separate) paragraph-start) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
352 (set (make-local-variable 'paragraph-ignore-fill-prefix) t) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
353 (set (make-local-variable 'require-final-newline) t) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
354 (set (make-local-variable 'parse-sexp-ignore-comments) t) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
355 (make-local-variable 'imenu-generic-expression) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
356 (setq imenu-generic-expression c++-imenu-generic-expression) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
357 (setq imenu-case-fold-search nil) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
358 (run-hooks 'c++-mode-hook) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
359 (if c++-electric-colon |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
360 (define-key c++-mode-map ":" 'electric-c++-terminator))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
361 |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
362 ;; This is used by indent-for-comment |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
363 ;; to decide how much to indent a comment in C++ code |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
364 ;; based on its context. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
365 (defun c++-comment-indent () |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
366 (if (looking-at "^\\(/\\*\\|//\\)") |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
367 0 ; Existing comment at bol stays there. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
368 (save-excursion |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
369 (skip-chars-backward " \t") |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
370 (max |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
371 ;; Leave at least one space on non-empty lines. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
372 (if (zerop (current-column)) 0 (1+ (current-column))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
373 (let ((cur-pt (point))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
374 (beginning-of-line 0) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
375 ;; If previous line had a comment, use its indentation. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
376 (if (re-search-forward comment-start-skip cur-pt t) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
377 (progn |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
378 (goto-char (match-beginning 0)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
379 (current-column)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
380 comment-column)))))) ; otherwise indent at comment column. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
381 |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
382 (defun electric-c++-brace (arg) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
383 "Insert character and correct line's indentation." |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
384 (interactive "P") |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
385 (let (insertpos) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
386 (if (and (not arg) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
387 (eolp) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
388 (or (save-excursion |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
389 (skip-chars-backward " \t") |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
390 (bolp)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
391 (if c-auto-newline (progn (c++-indent-line) (newline) t)))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
392 (progn |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
393 (insert last-command-char) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
394 (c++-indent-line) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
395 (if c-auto-newline |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
396 (progn |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
397 (newline) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
398 ;; (newline) may have done auto-fill |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
399 (setq insertpos (- (point) 2)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
400 (c++-indent-line))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
401 (save-excursion |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
402 (if insertpos (goto-char (1+ insertpos))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
403 (delete-char -1)))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
404 (if insertpos |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
405 (save-excursion |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
406 (goto-char insertpos) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
407 (self-insert-command (prefix-numeric-value arg))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
408 (self-insert-command (prefix-numeric-value arg))))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
409 |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
410 (defun electric-c++-semi (arg) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
411 "Insert character and correct line's indentation." |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
412 (interactive "P") |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
413 (if c-auto-newline |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
414 (electric-c++-terminator arg) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
415 (self-insert-command (prefix-numeric-value arg)))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
416 |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
417 (defun electric-c++-terminator (arg) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
418 "Insert character and correct line's indentation." |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
419 (interactive "P") |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
420 (let (insertpos (end (point))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
421 (if (and (not arg) (eolp) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
422 (not (save-excursion |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
423 (beginning-of-line) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
424 (skip-chars-forward " \t") |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
425 (or (= (following-char) ?#) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
426 ;; Colon is special only after a label, or |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
427 ;; case, or another colon. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
428 ;; So quickly rule out most other uses of colon |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
429 ;; and do no indentation for them. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
430 (and (eq last-command-char ?:) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
431 (or (not (or (looking-at "case[ \t]") |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
432 (save-excursion |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
433 (forward-word 1) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
434 (skip-chars-forward " \t") |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
435 (>= (point) end)))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
436 ;; Do re-indent double colons |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
437 (save-excursion |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
438 (end-of-line 1) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
439 (looking-at ":")))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
440 (progn |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
441 (beginning-of-defun) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
442 (let ((pps (parse-partial-sexp (point) end))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
443 (or (nth 3 pps) (nth 4 pps) (nth 5 pps)))))))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
444 (progn |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
445 (insert last-command-char) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
446 (c++-indent-line) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
447 (and c-auto-newline |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
448 (not (c-inside-parens-p)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
449 (progn |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
450 ;; the new marker object, used to be just an integer |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
451 (setq insertpos (make-marker)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
452 ;; changed setq to set-marker |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
453 (set-marker insertpos (1- (point))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
454 ;; do this before the newline, since in auto fill can break |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
455 (newline) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
456 (c-indent-line))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
457 (save-excursion |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
458 (if insertpos (goto-char (1+ insertpos))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
459 (delete-char -1)))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
460 (if insertpos |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
461 (save-excursion |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
462 (goto-char insertpos) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
463 (self-insert-command (prefix-numeric-value arg))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
464 (self-insert-command (prefix-numeric-value arg))))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
465 |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
466 (defun c++-indent-command (&optional whole-exp) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
467 "Indent current line as C++ code, or in some cases insert a tab character. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
468 If `c-tab-always-indent' is non-nil (the default), always indent current |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
469 line. Otherwise, indent the current line only if point is at the left |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
470 margin or in the line's indentation; otherwise insert a tab. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
471 |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
472 A numeric argument, regardless of its value, means indent rigidly all means |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
473 indent rigidly all the lines of the expression starting after point so that |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
474 this line becomes properly indented. The relative indentation among the |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
475 lines of the expression are preserved." |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
476 (interactive "P") |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
477 (if whole-exp |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
478 ;; If arg, always indent this line as C |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
479 ;; and shift remaining lines of expression the same amount. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
480 (let ((shift-amt (c++-indent-line)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
481 beg end) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
482 (save-excursion |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
483 (if c-tab-always-indent |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
484 (beginning-of-line)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
485 (setq beg (point)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
486 (forward-sexp 1) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
487 (setq end (point)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
488 (goto-char beg) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
489 (forward-line 1) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
490 (setq beg (point))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
491 (if (> end beg) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
492 (indent-code-rigidly beg end shift-amt "#"))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
493 (if (and (not c-tab-always-indent) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
494 (save-excursion |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
495 (skip-chars-backward " \t") |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
496 (not (bolp)))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
497 (insert-tab) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
498 (c++-indent-line)))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
499 |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
500 (defun c++-indent-line () |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
501 "Indent current line as C++ code. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
502 Return the amount the indentation changed by." |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
503 (let ((indent (calculate-c++-indent nil)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
504 beg shift-amt |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
505 (case-fold-search nil) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
506 (pos (- (point-max) (point)))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
507 (beginning-of-line) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
508 (setq beg (point)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
509 (cond ((eq indent nil) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
510 (setq indent (current-indentation))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
511 ((eq indent t) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
512 (setq indent (calculate-c-indent-within-comment))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
513 ((looking-at "[ \t]*#") |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
514 (setq indent 0)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
515 (t |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
516 (skip-chars-forward " \t") |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
517 (if (listp indent) (setq indent (car indent))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
518 (cond ((looking-at "\\(default\\|public\\|private\\|protected\\):") |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
519 (setq indent (+ indent c-label-offset))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
520 ((or (looking-at "case\\b") |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
521 (and (looking-at "[A-Za-z]") |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
522 (save-excursion |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
523 (forward-sexp 1) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
524 (looking-at ":[^:]")))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
525 (setq indent (max 1 (+ indent c-label-offset)))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
526 ((and (looking-at "else\\b") |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
527 (not (looking-at "else\\s_"))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
528 (setq indent (save-excursion |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
529 (c-backward-to-start-of-if) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
530 (current-indentation)))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
531 ((looking-at "friend\[ \t]") |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
532 (setq indent (+ indent c++-friend-offset))) |
41609 | 533 ((= (following-char) ?\}) |
36927
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
534 (setq indent (- indent c-indent-level))) |
41609 | 535 ((= (following-char) ?\{) |
36927
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
536 (setq indent (+ indent c-brace-offset)))))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
537 (skip-chars-forward " \t") |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
538 (setq shift-amt (- indent (current-column))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
539 (if (zerop shift-amt) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
540 (if (> (- (point-max) pos) (point)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
541 (goto-char (- (point-max) pos))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
542 (delete-region beg (point)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
543 (indent-to indent) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
544 ;; If initial point was within line's indentation, |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
545 ;; position after the indentation. Else stay at same point in text. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
546 (if (> (- (point-max) pos) (point)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
547 (goto-char (- (point-max) pos)))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
548 shift-amt)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
549 |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
550 (defun calculate-c++-indent (&optional parse-start) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
551 "Return appropriate indentation for current line as C++ code. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
552 In usual case returns an integer: the column to indent to. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
553 Returns nil if line starts inside a string, t if in a comment." |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
554 (save-excursion |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
555 (beginning-of-line) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
556 (let ((indent-point (point)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
557 (case-fold-search nil) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
558 state |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
559 containing-sexp) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
560 (if parse-start |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
561 (goto-char parse-start) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
562 (beginning-of-defun)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
563 (while (< (point) indent-point) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
564 (setq parse-start (point)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
565 (setq state (parse-partial-sexp (point) indent-point 0)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
566 (setq containing-sexp (car (cdr state)))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
567 (cond ((or (nth 3 state) (nth 4 state)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
568 ;; return nil or t if should not change this line |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
569 (nth 4 state)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
570 ((null containing-sexp) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
571 ;; Line is at top level. May be data or function definition, or |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
572 ;; may be function argument declaration or member initialization. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
573 ;; Indent like the previous top level line unless |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
574 ;; (1) the previous line ends in a closeparen without semicolon, |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
575 ;; in which case this line is the first argument declaration or |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
576 ;; member initialization, or |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
577 ;; (2) the previous line begins with a colon, |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
578 ;; in which case this is the second line of member inits. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
579 ;; It is assumed that arg decls and member inits are not mixed. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
580 (goto-char indent-point) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
581 (skip-chars-forward " \t") |
41609 | 582 (if (= (following-char) ?\{) |
36927
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
583 0 ; Unless it starts a function body |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
584 (c++-backward-to-noncomment (or parse-start (point-min))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
585 (if (= (preceding-char) ?\)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
586 (progn ; first arg decl or member init |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
587 (goto-char indent-point) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
588 (skip-chars-forward " \t") |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
589 (if (= (following-char) ?:) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
590 c++-member-init-indent |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
591 c-argdecl-indent)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
592 (if (= (preceding-char) ?\;) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
593 (backward-char 1)) |
41609 | 594 (if (= (preceding-char) ?\}) |
36927
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
595 0 |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
596 (if (= (preceding-char) ?\)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
597 (forward-list -1)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
598 (beginning-of-line) ; continued arg decls or member inits |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
599 (skip-chars-forward " \t") |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
600 (if (= (following-char) ?:) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
601 (if c++-continued-member-init-offset |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
602 (+ (current-indentation) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
603 c++-continued-member-init-offset) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
604 (progn |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
605 (forward-char 1) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
606 (skip-chars-forward " \t") |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
607 (current-column))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
608 (current-indentation))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
609 ))) |
41609 | 610 ((/= (char-after containing-sexp) ?\{) |
36927
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
611 ;; line is expression, not statement: |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
612 ;; indent to just after the surrounding open -- unless |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
613 ;; empty arg list, in which case we do what |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
614 ;; c++-empty-arglist-indent says to do. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
615 (if (and c++-empty-arglist-indent |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
616 (or (null (nth 2 state)) ;; indicates empty arg |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
617 ;; list. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
618 ;; Use a heuristic: if the first |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
619 ;; non-whitespace following left paren on |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
620 ;; same line is not a comment, |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
621 ;; is not an empty arglist. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
622 (save-excursion |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
623 (goto-char (1+ containing-sexp)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
624 (not |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
625 (looking-at "\\( \\|\t\\)*[^/\n]"))))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
626 (progn |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
627 (goto-char containing-sexp) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
628 (beginning-of-line) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
629 (skip-chars-forward " \t") |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
630 (goto-char (min (+ (point) c++-empty-arglist-indent) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
631 (1+ containing-sexp))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
632 (current-column)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
633 ;; In C-mode, we would always indent to one after the |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
634 ;; left paren. Here, though, we may have an |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
635 ;; empty-arglist, so we'll indent to the min of that |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
636 ;; and the beginning of the first argument. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
637 (goto-char (1+ containing-sexp)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
638 (current-column))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
639 (t |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
640 ;; Statement. Find previous non-comment character. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
641 (goto-char indent-point) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
642 (c++-backward-to-noncomment containing-sexp) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
643 (if (and (not (memq (preceding-char) '(0 ?\, ?\; ?\} ?\{))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
644 ;; But don't treat a line with a close-brace |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
645 ;; as a continuation. It is probably the |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
646 ;; end of an enum type declaration. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
647 (save-excursion |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
648 (goto-char indent-point) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
649 (skip-chars-forward " \t") |
41609 | 650 (not (= (following-char) ?\})))) |
36927
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
651 ;; This line is continuation of preceding line's statement; |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
652 ;; indent c-continued-statement-offset more than the |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
653 ;; previous line of the statement. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
654 (progn |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
655 (c-backward-to-start-of-continued-exp containing-sexp) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
656 (+ c-continued-statement-offset (current-column) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
657 (if (save-excursion (goto-char indent-point) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
658 (skip-chars-forward " \t") |
41609 | 659 (eq (following-char) ?\{)) |
36927
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
660 c-continued-brace-offset 0))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
661 ;; This line starts a new statement. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
662 ;; Position following last unclosed open. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
663 (goto-char containing-sexp) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
664 ;; Is line first statement after an open-brace? |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
665 (or |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
666 ;; If no, find that first statement and indent like it. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
667 (save-excursion |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
668 (forward-char 1) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
669 (let ((colon-line-end 0)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
670 (while (progn (skip-chars-forward " \t\n") |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
671 (looking-at |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
672 (concat |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
673 "#\\|/\\*\\|//" |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
674 "\\|case[ \t]" |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
675 "\\|[a-zA-Z0-9_$]*:[^:]" |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
676 "\\|friend[ \t]"))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
677 ;; Skip over comments and labels following openbrace. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
678 (cond ((= (following-char) ?\#) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
679 (forward-line 1)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
680 ((looking-at "/\\*") |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
681 (search-forward "*/" nil 'move)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
682 ((looking-at "//\\|friend[ \t]") |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
683 (forward-line 1)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
684 (t |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
685 (save-excursion (end-of-line) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
686 (setq colon-line-end (point))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
687 (search-forward ":")))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
688 ;; The first following code counts |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
689 ;; if it is before the line we want to indent. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
690 (and (< (point) indent-point) |
41609 | 691 (- |
36927
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
692 (if (> colon-line-end (point)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
693 (- (current-indentation) c-label-offset) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
694 (current-column)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
695 ;; If prev stmt starts with open-brace, that |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
696 ;; open brace was offset by c-brace-offset. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
697 ;; Compensate to get the column where |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
698 ;; an ordinary statement would start. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
699 (if (= (following-char) ?\{) c-brace-offset 0))))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
700 ;; If no previous statement, |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
701 ;; indent it relative to line brace is on. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
702 ;; For open brace in column zero, don't let statement |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
703 ;; start there too. If c-indent-offset is zero, |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
704 ;; use c-brace-offset + c-continued-statement-offset instead. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
705 ;; For open-braces not the first thing in a line, |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
706 ;; add in c-brace-imaginary-offset. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
707 (+ (if (and (bolp) (zerop c-indent-level)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
708 (+ c-brace-offset c-continued-statement-offset) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
709 c-indent-level) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
710 ;; Move back over whitespace before the openbrace. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
711 ;; If openbrace is not first nonwhite thing on the line, |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
712 ;; add the c-brace-imaginary-offset. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
713 (progn (skip-chars-backward " \t") |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
714 (if (bolp) 0 c-brace-imaginary-offset)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
715 ;; If the openbrace is preceded by a parenthesized exp, |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
716 ;; move to the beginning of that; |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
717 ;; possibly a different line |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
718 (progn |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
719 (if (eq (preceding-char) ?\)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
720 (forward-sexp -1)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
721 ;; Get initial indentation of the line we are on. |
41609 | 722 (current-indentation)))))))))) |
36927
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
723 |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
724 (defun c++-backward-to-noncomment (lim) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
725 (let (opoint stop) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
726 (while (not stop) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
727 (skip-chars-backward " \t\n\r\f" lim) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
728 (setq opoint (point)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
729 (cond ((and (>= (point) (+ 2 lim)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
730 (save-excursion |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
731 (forward-char -2) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
732 (looking-at "\\*/"))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
733 (search-backward "/*" lim 'move)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
734 ((and |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
735 (search-backward "//" (max (c++-point-bol) lim) 'move) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
736 (not (c++-within-string-p (point) opoint)))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
737 ;; No comment to be found. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
738 ;; If there's a # command on this line, |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
739 ;; move back to it. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
740 (t (beginning-of-line) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
741 (skip-chars-forward " \t") |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
742 ;; But don't get fooled if we are already before the #. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
743 (if (and (looking-at "#") (< (point) opoint)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
744 (setq stop (<= (point) lim)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
745 (setq stop t) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
746 (goto-char opoint))))))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
747 |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
748 (defun indent-c++-exp () |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
749 "Indent each line of the C++ grouping following point." |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
750 (interactive) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
751 (let ((indent-stack (list nil)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
752 (contain-stack (list (point))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
753 (case-fold-search nil) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
754 restart outer-loop-done inner-loop-done state ostate |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
755 this-indent last-sexp last-depth |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
756 at-else at-brace |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
757 (opoint (point)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
758 (next-depth 0)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
759 (save-excursion |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
760 (forward-sexp 1)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
761 (save-excursion |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
762 (setq outer-loop-done nil) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
763 (while (and (not (eobp)) (not outer-loop-done)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
764 (setq last-depth next-depth) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
765 ;; Compute how depth changes over this line |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
766 ;; plus enough other lines to get to one that |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
767 ;; does not end inside a comment or string. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
768 ;; Meanwhile, do appropriate indentation on comment lines. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
769 (setq inner-loop-done nil) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
770 (while (and (not inner-loop-done) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
771 (not (and (eobp) (setq outer-loop-done t)))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
772 (setq ostate state) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
773 (setq state (parse-partial-sexp (point) (progn (end-of-line) (point)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
774 nil nil state)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
775 (setq next-depth (car state)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
776 (if (and (car (cdr (cdr state))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
777 (>= (car (cdr (cdr state))) 0)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
778 (setq last-sexp (car (cdr (cdr state))))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
779 (if (or (nth 4 ostate)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
780 (c++-indent-line)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
781 (if (or (nth 3 state)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
782 (forward-line 1) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
783 (setq inner-loop-done t))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
784 (if (<= next-depth 0) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
785 (setq outer-loop-done t)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
786 (if outer-loop-done |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
787 nil |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
788 ;; If this line had ..))) (((.. in it, pop out of the levels |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
789 ;; that ended anywhere in this line, even if the final depth |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
790 ;; doesn't indicate that they ended. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
791 (while (> last-depth (nth 6 state)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
792 (setq indent-stack (cdr indent-stack) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
793 contain-stack (cdr contain-stack) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
794 last-depth (1- last-depth))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
795 (if (/= last-depth next-depth) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
796 (setq last-sexp nil)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
797 ;; Add levels for any parens that were started in this line. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
798 (while (< last-depth next-depth) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
799 (setq indent-stack (cons nil indent-stack) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
800 contain-stack (cons nil contain-stack) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
801 last-depth (1+ last-depth))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
802 (if (null (car contain-stack)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
803 (setcar contain-stack (or (car (cdr state)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
804 (save-excursion (forward-sexp -1) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
805 (point))))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
806 (forward-line 1) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
807 (skip-chars-forward " \t") |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
808 (if (eolp) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
809 nil |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
810 (if (and (car indent-stack) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
811 (>= (car indent-stack) 0)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
812 ;; Line is on an existing nesting level. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
813 ;; Lines inside parens are handled specially. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
814 nil |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
815 ;; Just started a new nesting level. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
816 ;; Compute the standard indent for this level. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
817 (let (val) |
41609 | 818 (if (= (char-after (car contain-stack)) ?\{) |
36927
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
819 (save-excursion |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
820 (goto-char (car contain-stack)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
821 (setq val (calculate-c-indent-after-brace))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
822 (setq val (calculate-c++-indent |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
823 (if (car indent-stack) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
824 (- (car indent-stack)))))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
825 (setcar indent-stack val))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
826 ;; Adjust line indentation according to its predecessor. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
827 (if (/= (char-after (car contain-stack)) ?\{) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
828 (setq this-indent (car indent-stack)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
829 ;; Line is at statement level. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
830 ;; Is it a new statement? Is it an else? |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
831 ;; Find last non-comment character before this line |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
832 (save-excursion |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
833 (setq at-else (looking-at "else\\W")) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
834 (setq at-brace (= (following-char) ?\{)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
835 (c++-backward-to-noncomment opoint) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
836 (if (not (memq (preceding-char) '(nil ?\, ?\; ?\} ?: ?\{))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
837 ;; Preceding line did not end in comma or semi; |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
838 ;; indent this line c-continued-statement-offset |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
839 ;; more than previous. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
840 (progn |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
841 (c-backward-to-start-of-continued-exp |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
842 (car contain-stack)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
843 (setq this-indent |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
844 (+ c-continued-statement-offset |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
845 (current-column) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
846 (if at-brace c-continued-brace-offset 0)))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
847 ;; Preceding line ended in comma or semi; |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
848 ;; use the standard indent for this level. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
849 (if at-else |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
850 (progn (c-backward-to-start-of-if opoint) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
851 (setq this-indent (current-indentation))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
852 (setq this-indent (car indent-stack)))))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
853 ;; Adjust line indentation according to its contents |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
854 (if (looking-at "\\(public\\|private\\|protected\\):") |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
855 (setq this-indent (- this-indent c-indent-level)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
856 (if (or (looking-at "case[ \t]") |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
857 (and (looking-at "[A-Za-z]") |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
858 (save-excursion |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
859 (forward-sexp 1) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
860 (looking-at ":[^:]")))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
861 (setq this-indent (max 1 (+ this-indent c-label-offset))))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
862 (if (looking-at "friend[ \t]") |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
863 (setq this-indent (+ this-indent c++-friend-offset))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
864 (if (= (following-char) ?\}) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
865 (setq this-indent (- this-indent c-indent-level))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
866 (if (= (following-char) ?\{) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
867 (setq this-indent (+ this-indent c-brace-offset))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
868 ;; Put chosen indentation into effect. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
869 (or (= (current-column) this-indent) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
870 (= (following-char) ?\#) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
871 (progn |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
872 (delete-region (point) (progn (beginning-of-line) (point))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
873 (indent-to this-indent))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
874 ;; Indent any comment following the text. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
875 (or (looking-at comment-start-skip) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
876 (if (re-search-forward comment-start-skip |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
877 (save-excursion (end-of-line) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
878 (point)) t) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
879 (progn |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
880 (indent-for-comment) |
41609 | 881 (beginning-of-line)))))))))) |
36927
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
882 |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
883 (defun fill-c++-comment () |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
884 "Fill a comment contained in consecutive lines containing point. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
885 The fill lines remain a comment." |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
886 (interactive) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
887 (save-excursion |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
888 (let ((save fill-prefix)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
889 (beginning-of-line 1) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
890 (save-excursion |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
891 (re-search-forward comment-start-skip |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
892 (save-excursion (end-of-line) (point)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
893 t) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
894 (goto-char (match-end 0)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
895 (set-fill-prefix)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
896 (while (looking-at fill-prefix) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
897 (previous-line 1)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
898 (next-line 1) |
41569
f403516f2134
(fill-c++-comment): Use insert instead of insert-string.
Pavel Janík <Pavel@Janik.cz>
parents:
36927
diff
changeset
|
899 (insert "\n") |
36927
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
900 (fill-paragraph nil) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
901 (delete-char -1) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
902 (setq fill-prefix save)))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
903 |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
904 (defun c++-point-bol () |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
905 "Returns the value of the point at the beginning of the current line." |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
906 (save-excursion |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
907 (beginning-of-line) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
908 (point))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
909 |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
910 ;; (defun c++-insert-header () |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
911 ;; "Insert header denoting C++ code at top of buffer." |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
912 ;; (interactive) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
913 ;; (save-excursion |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
914 ;; (goto-char (point-min)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
915 ;; (insert "// " |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
916 ;; "This may look like C code, but it is really " |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
917 ;; "-*- C++ -*-" |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
918 ;; "\n\n"))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
919 |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
920 (defun c++-within-string-p (point1 point2) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
921 "Returns true if number of double quotes between two points is odd." |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
922 (let ((s (buffer-substring point1 point2))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
923 (not (zerop (% (c++-count-char-in-string ?\" s) 2))))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
924 |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
925 (defun c++-count-char-in-string (c s) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
926 (let ((count 0) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
927 (pos 0)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
928 (while (< pos (length s)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
929 (setq count (+ count (if (\= (aref s pos) c) 1 0))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
930 (setq pos (1+ pos))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
931 count)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
932 |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
933 ;; rms: This page is creeping featurism, and not worth having. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
934 |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
935 ;;; Below are two regular expressions that attempt to match defuns |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
936 ;;; "strongly" and "weakly." The strong one almost reconstructs the |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
937 ;;; grammar of C++; the weak one just figures anything id or curly on |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
938 ;;; the left begins a defun. The constant "c++-match-header-strongly" |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
939 ;;; determines which to use; the default is the weak one. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
940 |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
941 ;; (defvar c++-match-header-strongly nil |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
942 ;; "*If nil, use `c++-defun-header-weak' to identify beginning of definitions. |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
943 ;; If non-nil, use `c++-defun-header-strong'.") |
41609 | 944 ;; |
36927
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
945 ;; (defvar c++-defun-header-strong-struct-equivs "\\(class\\|struct\\|enum\\)" |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
946 ;; "Regexp to match names of structure declaration blocks in C++.") |
41609 | 947 ;; |
36927
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
948 ;; (defconst c++-defun-header-strong |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
949 ;; (let* |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
950 ;; (; valid identifiers |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
951 ;; ;; There's a real weirdness here -- if I switch the below |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
952 ;; (id "\\(\\w\\|_\\)+") |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
953 ;; ;; to be |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
954 ;; ;; (id "\\(_\\|\\w\\)+") |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
955 ;; ;; things no longer work right. Try it and see! |
41609 | 956 ;; |
36927
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
957 ;; ; overloadable operators |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
958 ;; (op-sym1 |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
959 ;; "[-+*/%^&|~!=<>]\\|[-+*/%^&|<>=!]=\\|<<=?\\|>>=?") |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
960 ;; (op-sym2 |
41609 | 961 ;; "&&\\|||\\|\\+\\+\\|--\\|()\\|\\[\\]") |
36927
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
962 ;; (op-sym (concat "\\(" op-sym1 "\\|" op-sym2 "\\)")) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
963 ;; ; whitespace |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
964 ;; (middle "[^\\*]*\\(\\*+[^/\\*][^\\*]*\\)*") |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
965 ;; (c-comment (concat "/\\*" middle "\\*+/")) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
966 ;; (wh (concat "\\(\\s \\|\n\\|//.*$\\|" c-comment "\\)")) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
967 ;; (wh-opt (concat wh "*")) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
968 ;; (wh-nec (concat wh "+")) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
969 ;; (oper (concat "\\(" "operator" "\\(" |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
970 ;; wh-opt op-sym "\\|" wh-nec id "\\)" "\\)")) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
971 ;; (dcl-list "([^():]*)") |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
972 ;; (func-name (concat "\\(" oper "\\|" id "::" id "\\|" id "\\)")) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
973 ;; (inits |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
974 ;; (concat "\\(:" |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
975 ;; "\\(" wh-opt id "(.*\\()" wh-opt "," "\\)\\)*" |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
976 ;; wh-opt id "(.*)" wh-opt "{" |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
977 ;; "\\|" wh-opt "{\\)")) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
978 ;; (type-name (concat |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
979 ;; "\\(" c++-defun-header-strong-struct-equivs wh-nec "\\)?" |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
980 ;; id)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
981 ;; (type (concat "\\(const" wh-nec "\\)?" |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
982 ;; "\\(" type-name "\\|" type-name wh-opt "\\*+" "\\|" |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
983 ;; type-name wh-opt "&" "\\)")) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
984 ;; (modifier "\\(inline\\|virtual\\|overload\\|auto\\|static\\)") |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
985 ;; (modifiers (concat "\\(" modifier wh-nec "\\)*")) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
986 ;; (func-header |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
987 ;; ;; type arg-dcl |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
988 ;; (concat modifiers type wh-nec func-name wh-opt dcl-list wh-opt inits)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
989 ;; (inherit (concat "\\(:" wh-opt "\\(public\\|private\\)?" |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
990 ;; wh-nec id "\\)")) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
991 ;; (cs-header (concat |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
992 ;; c++-defun-header-strong-struct-equivs |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
993 ;; wh-nec id wh-opt inherit "?" wh-opt "{"))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
994 ;; (concat "^\\(" func-header "\\|" cs-header "\\)")) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
995 ;; "Strongly-defined regexp to match beginning of structure or function def.") |
41609 | 996 ;; |
997 ;; | |
36927
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
998 ;; ;; This part has to do with recognizing defuns. |
41609 | 999 ;; |
36927
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1000 ;; ;; The weak convention we will use is that a defun begins any time |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1001 ;; ;; there is a left curly brace, or some identifier on the left margin, |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1002 ;; ;; followed by a left curly somewhere on the line. (This will also |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1003 ;; ;; incorrectly match some continued strings, but this is after all |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1004 ;; ;; just a weak heuristic.) Suggestions for improvement (short of the |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1005 ;; ;; strong scheme shown above) are welcomed. |
41609 | 1006 ;; |
36927
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1007 ;; (defconst c++-defun-header-weak "^{\\|^[_a-zA-Z].*{" |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1008 ;; "Weakly-defined regexp to match beginning of structure or function def.") |
41609 | 1009 ;; |
36927
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1010 ;; (defun c++-beginning-of-defun (arg) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1011 ;; (interactive "p") |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1012 ;; (let ((c++-defun-header (if c++-match-header-strongly |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1013 ;; c++-defun-header-strong |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1014 ;; c++-defun-header-weak))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1015 ;; (cond ((or (= arg 0) (and (> arg 0) (bobp))) nil) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1016 ;; ((and (not (looking-at c++-defun-header)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1017 ;; (let ((curr-pos (point)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1018 ;; (open-pos (if (search-forward "{" nil 'move) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1019 ;; (point))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1020 ;; (beg-pos |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1021 ;; (if (re-search-backward c++-defun-header nil 'move) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1022 ;; (match-beginning 0)))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1023 ;; (if (and open-pos beg-pos |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1024 ;; (< beg-pos curr-pos) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1025 ;; (> open-pos curr-pos)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1026 ;; (progn |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1027 ;; (goto-char beg-pos) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1028 ;; (if (= arg 1) t nil));; Are we done? |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1029 ;; (goto-char curr-pos) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1030 ;; nil)))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1031 ;; (t |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1032 ;; (if (and (looking-at c++-defun-header) (not (bobp))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1033 ;; (forward-char (if (< arg 0) 1 -1))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1034 ;; (and (re-search-backward c++-defun-header nil 'move (or arg 1)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1035 ;; (goto-char (match-beginning 0))))))) |
41609 | 1036 ;; |
1037 ;; | |
36927
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1038 ;; (defun c++-end-of-defun (arg) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1039 ;; (interactive "p") |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1040 ;; (let ((c++-defun-header (if c++-match-header-strongly |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1041 ;; c++-defun-header-strong |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1042 ;; c++-defun-header-weak))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1043 ;; (if (and (eobp) (> arg 0)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1044 ;; nil |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1045 ;; (if (and (> arg 0) (looking-at c++-defun-header)) (forward-char 1)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1046 ;; (let ((pos (point))) |
41609 | 1047 ;; (c++-beginning-of-defun |
36927
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1048 ;; (if (< arg 0) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1049 ;; (- (- arg (if (eobp) 0 1))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1050 ;; arg)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1051 ;; (if (and (< arg 0) (bobp)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1052 ;; t |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1053 ;; (if (re-search-forward c++-defun-header nil 'move) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1054 ;; (progn (forward-char -1) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1055 ;; (forward-sexp) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1056 ;; (beginning-of-line 2))) |
41609 | 1057 ;; (if (and (= pos (point)) |
36927
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1058 ;; (re-search-forward c++-defun-header nil 'move)) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1059 ;; (c++-end-of-defun 1)))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1060 ;; t))) |
41609 | 1061 ;; |
36927
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1062 ;; (defun c++-indent-defun () |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1063 ;; "Indents the current function definition, struct or class declaration." |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1064 ;; (interactive) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1065 ;; (let ((restore (point))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1066 ;; (c++-end-of-defun 1) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1067 ;; (beginning-of-line 1) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1068 ;; (let ((end (point))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1069 ;; (c++-beginning-of-defun 1) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1070 ;; (while (<= (point) end) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1071 ;; (c++-indent-line) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1072 ;; (next-line 1) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1073 ;; (beginning-of-line 1))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1074 ;; (goto-char restore))) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1075 |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1076 (provide 'cplus-md) |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1077 |
f6b815c4d2de
Moved from progmodes/cplus-md.el to obsolete/cplus-md.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1078 ;;; cplus-md.el ends here |