Mercurial > emacs
annotate lisp/progmodes/cc-align.el @ 110093:cb103d02d7f5
gnus-html.el: Add extra logging.
author | Katsumi Yamaoka <yamaoka@jpl.org> |
---|---|
date | Wed, 01 Sep 2010 23:46:59 +0000 |
parents | 280c8ae2476d |
children | 417b1e4d63cd |
rev | line source |
---|---|
18720 | 1 ;;; cc-align.el --- custom indentation functions for CC Mode |
2 | |
74372 | 3 ;; Copyright (C) 1985, 1987, 1992, 1993, 1994, 1995, 1996, 1997, 1998, |
106815 | 4 ;; 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 |
75347 | 5 ;; Free Software Foundation, Inc. |
18720 | 6 |
75307 | 7 ;; Authors: 2004- Alan Mackenzie |
8 ;; 1998- Martin Stjernholm | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
9 ;; 1992-1999 Barry A. Warsaw |
101112
0685234e527d
Comment (minor header format fixes).
Glenn Morris <rgm@gnu.org>
parents:
101002
diff
changeset
|
10 ;; 1987 Dave Detlefs |
0685234e527d
Comment (minor header format fixes).
Glenn Morris <rgm@gnu.org>
parents:
101002
diff
changeset
|
11 ;; 1987 Stewart Clamen |
18720 | 12 ;; 1985 Richard M. Stallman |
24282 | 13 ;; Maintainer: bug-cc-mode@gnu.org |
18720 | 14 ;; Created: 22-Apr-1997 (split from cc-mode.el) |
110015
280c8ae2476d
Add "Package:" file headers to denote built-in packages.
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
15 ;; Keywords: c languages |
280c8ae2476d
Add "Package:" file headers to denote built-in packages.
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
16 ;; Package: cc-mode |
18720 | 17 |
18 ;; This file is part of GNU Emacs. | |
19 | |
94673
52b7a8c22af5
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
20 ;; GNU Emacs is free software: you can redistribute it and/or modify |
18720 | 21 ;; it under the terms of the GNU General Public License as published by |
94673
52b7a8c22af5
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
22 ;; the Free Software Foundation, either version 3 of the License, or |
52b7a8c22af5
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
23 ;; (at your option) any later version. |
18720 | 24 |
25 ;; GNU Emacs is distributed in the hope that it will be useful, | |
26 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
27 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
28 ;; GNU General Public License for more details. | |
29 | |
30 ;; You should have received a copy of the GNU General Public License | |
94673
52b7a8c22af5
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
31 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
18720 | 32 |
38422
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
36920
diff
changeset
|
33 ;;; Commentary: |
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
36920
diff
changeset
|
34 |
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
36920
diff
changeset
|
35 ;;; Code: |
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
36920
diff
changeset
|
36 |
18720 | 37 (eval-when-compile |
26817 | 38 (let ((load-path |
36920 | 39 (if (and (boundp 'byte-compile-dest-file) |
40 (stringp byte-compile-dest-file)) | |
41 (cons (file-name-directory byte-compile-dest-file) load-path) | |
26817 | 42 load-path))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
43 (load "cc-bytecomp" nil t))) |
36920 | 44 |
45 (cc-require 'cc-defs) | |
46 (cc-require 'cc-vars) | |
47 (cc-require 'cc-engine) | |
18720 | 48 |
49 | |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
50 ;; Standard line-up functions |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
51 ;; |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
52 ;; See the section "Custom Indentation Functions" in the manual for |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
53 ;; details on the calling convention. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
54 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
55 (defun c-lineup-topmost-intro-cont (langelem) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
56 "Line up declaration continuation lines zero or one indentation step. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
57 For lines in the \"header\" of a definition, zero is used. For other |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
58 lines, `c-basic-offset' is added to the indentation. E.g: |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
59 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
60 int |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
61 neg (int i) <- c-lineup-topmost-intro-cont |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
62 { |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
63 return -i; |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
64 } |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
65 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
66 struct |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
67 larch <- c-lineup-topmost-intro-cont |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
68 { |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
69 double height; |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
70 } |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
71 the_larch, <- c-lineup-topmost-intro-cont |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
72 another_larch; <- c-lineup-topmost-intro-cont |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
73 <--> c-basic-offset |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
74 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
75 struct larch |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
76 the_larch, <- c-lineup-topmost-intro-cont |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
77 another_larch; <- c-lineup-topmost-intro-cont |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
78 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
79 \(This function is mainly provided to mimic the behavior of CC Mode |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
80 5.28 and earlier where this case wasn't handled consistently so that |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
81 these lines could be analyzed as either topmost-intro-cont or |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
82 statement-cont.) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
83 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
84 Works with: topmost-intro-cont." |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
85 (save-excursion |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
86 (beginning-of-line) |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
87 (c-backward-syntactic-ws (c-langelem-pos langelem)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
88 (if (and (memq (char-before) '(?} ?,)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
89 (not (and c-overloadable-operators-regexp |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
90 (c-after-special-operator-id)))) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
91 c-basic-offset))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
92 |
75027
9f636bd65206
Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents:
74372
diff
changeset
|
93 (defun c-lineup-gnu-DEFUN-intro-cont (langelem) |
9f636bd65206
Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents:
74372
diff
changeset
|
94 "Line up the continuation lines of a DEFUN macro in the Emacs C source. |
9f636bd65206
Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents:
74372
diff
changeset
|
95 These lines are indented as though they were `knr-argdecl-intro' lines. |
9f636bd65206
Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents:
74372
diff
changeset
|
96 Return nil when we're not in such a construct. |
9f636bd65206
Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents:
74372
diff
changeset
|
97 |
9f636bd65206
Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents:
74372
diff
changeset
|
98 This function is for historical compatibility with how previous CC Modes (5.28 |
9f636bd65206
Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents:
74372
diff
changeset
|
99 and earlier) indented such lines. |
9f636bd65206
Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents:
74372
diff
changeset
|
100 |
9f636bd65206
Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents:
74372
diff
changeset
|
101 Here is an example: |
9f636bd65206
Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents:
74372
diff
changeset
|
102 |
9f636bd65206
Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents:
74372
diff
changeset
|
103 DEFUN (\"forward-char\", Fforward_char, Sforward_char, 0, 1, \"p\", |
9f636bd65206
Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents:
74372
diff
changeset
|
104 doc: /* Move point right N characters (left if N is negative). |
9f636bd65206
Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents:
74372
diff
changeset
|
105 On reaching end of buffer, stop and signal error. */) |
9f636bd65206
Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents:
74372
diff
changeset
|
106 (n) <- c-lineup-gnu-DEFUN-into-cont |
9f636bd65206
Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents:
74372
diff
changeset
|
107 Lisp_Object n; <- c-lineup-gnu-DEFUN-into-cont |
9f636bd65206
Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents:
74372
diff
changeset
|
108 |
9f636bd65206
Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents:
74372
diff
changeset
|
109 Works with: topmost-intro-cont." |
9f636bd65206
Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents:
74372
diff
changeset
|
110 (save-excursion |
9f636bd65206
Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents:
74372
diff
changeset
|
111 (let (case-fold-search) |
9f636bd65206
Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents:
74372
diff
changeset
|
112 (goto-char (c-langelem-pos langelem)) |
9f636bd65206
Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents:
74372
diff
changeset
|
113 (if (looking-at "\\<DEFUN\\>") |
9f636bd65206
Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents:
74372
diff
changeset
|
114 (c-calc-offset '(knr-argdecl-intro)))))) |
9f636bd65206
Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents:
74372
diff
changeset
|
115 |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
116 (defun c-block-in-arglist-dwim (arglist-start) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
117 ;; This function implements the DWIM to avoid far indentation of |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
118 ;; brace block constructs in arguments in `c-lineup-arglist' etc. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
119 ;; Return non-nil if a brace block construct is detected within the |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
120 ;; arglist starting at ARGLIST-START. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
121 |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
122 (or |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
123 ;; Check if the syntactic context contains any of the symbols for |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
124 ;; in-expression constructs. This can both save the work that we |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
125 ;; have to do below, and it also detect the brace list constructs |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
126 ;; that `c-looking-at-inexpr-block' currently misses (they are |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
127 ;; recognized by `c-inside-bracelist-p' instead). |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
128 (assq 'inexpr-class c-syntactic-context) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
129 (assq 'inexpr-statement c-syntactic-context) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
130 (assq 'inlambda c-syntactic-context) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
131 |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
132 (save-restriction |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
133 ;; Search for open braces from the arglist start to the end of the |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
134 ;; line. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
135 (narrow-to-region arglist-start (c-point 'eol arglist-start)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
136 |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
137 (goto-char arglist-start) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
138 (while (and (c-syntactic-re-search-forward "{" nil t) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
139 (progn |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
140 (backward-char) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
141 (or |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
142 ;; Ignore starts of special brace lists. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
143 (and c-special-brace-lists |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
144 (save-restriction |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
145 (widen) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
146 (c-looking-at-special-brace-list))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
147 ;; Ignore complete blocks. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
148 (c-safe (c-forward-sexp) t)))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
149 (forward-char)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
150 |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
151 (looking-at "{")) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
152 |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
153 (let (containing-sexp) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
154 (goto-char arglist-start) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
155 ;; `c-syntactic-eol' always matches somewhere on the line. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
156 (re-search-forward c-syntactic-eol) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
157 (goto-char (match-beginning 0)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
158 (c-forward-syntactic-ws) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
159 (setq containing-sexp (c-most-enclosing-brace (c-parse-state))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
160 (c-looking-at-inexpr-block |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
161 (c-safe-position (or containing-sexp (point)) c-state-cache) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
162 containing-sexp)))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
163 |
18720 | 164 (defun c-lineup-arglist (langelem) |
26817 | 165 "Line up the current argument line under the first argument. |
166 | |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
167 As a special case, if the indented line is inside a brace block |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
168 construct, the indentation is `c-basic-offset' only. This is intended |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
169 as a \"DWIM\" measure in cases like macros that contains statement |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
170 blocks, e.g: |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
171 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
172 A_VERY_LONG_MACRO_NAME ({ |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
173 some (code, with + long, lines * in[it]); |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
174 }); |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
175 <--> c-basic-offset |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
176 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
177 This is motivated partly because it's more in line with how code |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
178 blocks are handled, and partly since it approximates the behavior of |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
179 earlier CC Mode versions, which due to inaccurate analysis tended to |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
180 indent such cases this way. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
181 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
182 Works with: arglist-cont-nonempty, arglist-close." |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
183 (save-excursion |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
184 (let ((indent-pos (point))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
185 |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
186 (if (c-block-in-arglist-dwim (c-langelem-2nd-pos c-syntactic-element)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
187 c-basic-offset ; DWIM case. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
188 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
189 ;; Normal case. Indent to the token after the arglist open paren. |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
190 (goto-char (c-langelem-2nd-pos c-syntactic-element)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
191 (if (and c-special-brace-lists |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
192 (c-looking-at-special-brace-list)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
193 ;; Skip a special brace list opener like "({". |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
194 (progn (c-forward-token-2) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
195 (forward-char)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
196 (forward-char)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
197 (let ((arglist-content-start (point))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
198 (c-forward-syntactic-ws) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
199 (when (< (point) indent-pos) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
200 (goto-char arglist-content-start) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
201 (skip-chars-forward " \t")) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
202 (vector (current-column))))))) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
203 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
204 ;; Contributed by Kevin Ryde <user42@zip.com.au>. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
205 (defun c-lineup-argcont (elem) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
206 "Line up a continued argument. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
207 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
208 foo (xyz, aaa + bbb + ccc |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
209 + ddd + eee + fff); <- c-lineup-argcont |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
210 |
50860
4fd35ed09e9b
(c-lineup-argcont, c-lineup-gcc-asm-reg): Don't quote nil and t in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
44728
diff
changeset
|
211 Only continuation lines like this are touched, nil is returned on lines |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
212 which are the start of an argument. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
213 |
63516
1975a7b1ec5f
(c-lineup-argcont): Fix spelling in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
62641
diff
changeset
|
214 Within a gcc asm block, \":\" is recognized as an argument separator, |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
215 but of course only between operand specifications, not in the expressions |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
216 for the operands. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
217 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
218 Works with: arglist-cont, arglist-cont-nonempty." |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
219 |
18720 | 220 (save-excursion |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
221 (beginning-of-line) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
222 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
223 (when (eq (car elem) 'arglist-cont-nonempty) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
224 ;; Our argument list might not be the innermost one. If it |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
225 ;; isn't, go back to the last position in it. We do this by |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
226 ;; stepping back over open parens until we get to the open paren |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
227 ;; of our argument list. |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
228 (let ((open-paren (c-langelem-2nd-pos c-syntactic-element)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
229 (paren-state (c-parse-state))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
230 (while (not (eq (car paren-state) open-paren)) |
62641
27b53b1903b6
2005-05-23 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
56646
diff
changeset
|
231 (unless (consp (car paren-state)) ;; ignore matched braces |
27b53b1903b6
2005-05-23 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
56646
diff
changeset
|
232 (goto-char (car paren-state))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
233 (setq paren-state (cdr paren-state))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
234 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
235 (let ((start (point)) c) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
236 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
237 (when (bolp) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
238 ;; Previous line ending in a comma means we're the start of an |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
239 ;; argument. This should quickly catch most cases not for us. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
240 ;; This case is only applicable if we're the innermost arglist. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
241 (c-backward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
242 (setq c (char-before))) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
243 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
244 (unless (eq c ?,) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
245 ;; In a gcc asm, ":" on the previous line means the start of an |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
246 ;; argument. And lines starting with ":" are not for us, don't |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
247 ;; want them to indent to the preceding operand. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
248 (let ((gcc-asm (save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
249 (goto-char start) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
250 (c-in-gcc-asm-p)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
251 (unless (and gcc-asm |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
252 (or (eq c ?:) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
253 (save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
254 (goto-char start) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
255 (looking-at "[ \t]*:")))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
256 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
257 (c-lineup-argcont-scan (if gcc-asm ?:)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
258 (vector (current-column)))))))) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
259 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
260 (defun c-lineup-argcont-scan (&optional other-match) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
261 ;; Find the start of an argument, for `c-lineup-argcont'. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
262 (when (zerop (c-backward-token-2 1 t)) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
263 (let ((c (char-after))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
264 (if (or (eq c ?,) (eq c other-match)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
265 (progn |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
266 (forward-char) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
267 (c-forward-syntactic-ws)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
268 (c-lineup-argcont-scan other-match))))) |
18720 | 269 |
270 (defun c-lineup-arglist-intro-after-paren (langelem) | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
271 "Line up a line to just after the open paren of the surrounding paren |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
272 or brace block. |
26817 | 273 |
274 Works with: defun-block-intro, brace-list-intro, | |
275 statement-block-intro, statement-case-intro, arglist-intro." | |
18720 | 276 (save-excursion |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
277 (beginning-of-line) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
278 (backward-up-list 1) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
279 (skip-chars-forward " \t" (c-point 'eol)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
280 (vector (1+ (current-column))))) |
18720 | 281 |
282 (defun c-lineup-arglist-close-under-paren (langelem) | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
283 "Line up a line under the enclosing open paren. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
284 Normally used to line up a closing paren in the same column as its |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
285 corresponding open paren, but can also be used with arglist-cont and |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
286 arglist-cont-nonempty to line up all lines inside a parenthesis under |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
287 the open paren. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
288 |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
289 As a special case, if a brace block construct starts at the same line |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
290 as the open parenthesis of the argument list, the indentation is |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
291 `c-basic-offset' only. See `c-lineup-arglist' for further discussion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
292 of this \"DWIM\" measure. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
293 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
294 Works with: Almost all symbols, but are typically most useful on |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
295 arglist-close, brace-list-close, arglist-cont and arglist-cont-nonempty." |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
296 (save-excursion |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
297 (if (memq (c-langelem-sym langelem) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
298 '(arglist-cont-nonempty arglist-close)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
299 (goto-char (c-langelem-2nd-pos c-syntactic-element)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
300 (beginning-of-line) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
301 (c-go-up-list-backward)) |
26817 | 302 |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
303 (if (save-excursion (c-block-in-arglist-dwim (point))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
304 c-basic-offset ; DWIM case. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
305 |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
306 ;; Normal case. Indent to the arglist open paren. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
307 (let (special-list) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
308 (if (and c-special-brace-lists |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
309 (setq special-list (c-looking-at-special-brace-list))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
310 ;; Cope if we're in the middle of a special brace list |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
311 ;; opener like "({". |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
312 (goto-char (car (car special-list)))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
313 (vector (current-column)))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
314 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
315 (defun c-lineup-arglist-operators (langelem) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
316 "Line up lines starting with an infix operator under the open paren. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
317 Return nil on lines that don't start with an operator, to leave those |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
318 cases to other line-up functions. Example: |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
319 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
320 if ( x < 10 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
321 || at_limit (x, <- c-lineup-arglist-operators |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
322 list) <- c-lineup-arglist-operators returns nil |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
323 ) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
324 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
325 Since this function doesn't do anything for lines without an infix |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
326 operator you typically want to use it together with some other line-up |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
327 settings, e.g. as follows \(the arglist-close setting is just a |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
328 suggestion to get a consistent style): |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
329 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
330 \(c-set-offset 'arglist-cont '(c-lineup-arglist-operators 0)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
331 \(c-set-offset 'arglist-cont-nonempty '(c-lineup-arglist-operators |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
332 c-lineup-arglist)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
333 \(c-set-offset 'arglist-close '(c-lineup-arglist-close-under-paren)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
334 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
335 Works with: arglist-cont, arglist-cont-nonempty." |
18720 | 336 (save-excursion |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
337 (back-to-indentation) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
338 (when (looking-at "[-+|&*%<>=]\\|\\(/[^/*]\\)") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
339 ;; '-' can be both an infix and a prefix operator, but I'm lazy now.. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
340 (c-lineup-arglist-close-under-paren langelem)))) |
18720 | 341 |
20911 | 342 (defun c-lineup-close-paren (langelem) |
26817 | 343 "Line up the closing paren under its corresponding open paren if the |
344 open paren is followed by code. If the open paren ends its line, no | |
345 indentation is added. E.g: | |
346 | |
347 main (int, main ( | |
348 char ** int, char ** | |
349 ) <-> ) <- c-lineup-close-paren | |
350 | |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
351 As a special case, if a brace block construct starts at the same line |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
352 as the open parenthesis of the argument list, the indentation is |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
353 `c-basic-offset' instead of the open paren column. See |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
354 `c-lineup-arglist' for further discussion of this \"DWIM\" measure. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
355 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
356 Works with: All *-close symbols." |
20911 | 357 (save-excursion |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
358 (if (memq (c-langelem-sym langelem) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
359 '(arglist-cont-nonempty arglist-close)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
360 (goto-char (c-langelem-2nd-pos c-syntactic-element)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
361 (beginning-of-line) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
362 (c-go-up-list-backward)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
363 |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
364 (let (special-list arglist-start) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
365 (if (and c-special-brace-lists |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
366 (setq special-list (c-looking-at-special-brace-list))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
367 ;; Cope if we're in the middle of a special brace list |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
368 ;; opener like "({". |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
369 (progn |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
370 (goto-char (setq arglist-start (car (car special-list)))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
371 (c-forward-token-2) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
372 (forward-char)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
373 (setq arglist-start (point)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
374 (forward-char)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
375 |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
376 (cond ((looking-at c-syntactic-eol) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
377 0) ; The arglist is "empty". |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
378 |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
379 ((c-block-in-arglist-dwim (point)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
380 c-basic-offset) ; DWIM case. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
381 |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
382 (t |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
383 ;; Normal case. Indent to the arglist open paren. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
384 (goto-char arglist-start) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
385 (vector (current-column))))))) |
20911 | 386 |
18720 | 387 (defun c-lineup-streamop (langelem) |
26817 | 388 "Line up C++ stream operators under each other. |
389 | |
390 Works with: stream-op." | |
18720 | 391 (save-excursion |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
392 (goto-char (c-langelem-pos langelem)) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
393 (re-search-forward "<<\\|>>" (c-point 'eol) 'move) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
394 (goto-char (match-beginning 0)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
395 (vector (current-column)))) |
18720 | 396 |
397 (defun c-lineup-multi-inher (langelem) | |
30407
b88ff2eabd4e
(c-lineup-multi-inher): Handle lines with
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
398 "Line up the classes in C++ multiple inheritance clauses and member |
b88ff2eabd4e
(c-lineup-multi-inher): Handle lines with
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
399 initializers under each other. E.g: |
b88ff2eabd4e
(c-lineup-multi-inher): Handle lines with
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
400 |
b88ff2eabd4e
(c-lineup-multi-inher): Handle lines with
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
401 class Foo: Foo::Foo (int a, int b): |
b88ff2eabd4e
(c-lineup-multi-inher): Handle lines with
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
402 public Cyphr, Cyphr (a), |
b88ff2eabd4e
(c-lineup-multi-inher): Handle lines with
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
403 public Bar <-> Bar (b) <- c-lineup-multi-inher |
26817 | 404 |
30407
b88ff2eabd4e
(c-lineup-multi-inher): Handle lines with
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
405 class Foo Foo::Foo (int a, int b) |
b88ff2eabd4e
(c-lineup-multi-inher): Handle lines with
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
406 : public Cyphr, : Cyphr (a), |
b88ff2eabd4e
(c-lineup-multi-inher): Handle lines with
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
407 public Bar <-> Bar (b) <- c-lineup-multi-inher |
b88ff2eabd4e
(c-lineup-multi-inher): Handle lines with
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
408 |
b88ff2eabd4e
(c-lineup-multi-inher): Handle lines with
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
409 class Foo Foo::Foo (int a, int b) |
b88ff2eabd4e
(c-lineup-multi-inher): Handle lines with
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
410 : public Cyphr : Cyphr (a) |
b88ff2eabd4e
(c-lineup-multi-inher): Handle lines with
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
411 , public Bar <-> , Bar (b) <- c-lineup-multi-inher |
b88ff2eabd4e
(c-lineup-multi-inher): Handle lines with
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
412 |
b88ff2eabd4e
(c-lineup-multi-inher): Handle lines with
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
413 Works with: inher-cont, member-init-cont." |
18720 | 414 (save-excursion |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
415 (back-to-indentation) |
30407
b88ff2eabd4e
(c-lineup-multi-inher): Handle lines with
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
416 (let* ((eol (c-point 'eol)) |
b88ff2eabd4e
(c-lineup-multi-inher): Handle lines with
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
417 (here (point)) |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
418 (char-after-ip (char-after))) |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
419 (if (c-langelem-pos langelem) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
420 (goto-char (c-langelem-pos langelem))) |
30407
b88ff2eabd4e
(c-lineup-multi-inher): Handle lines with
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
421 |
b88ff2eabd4e
(c-lineup-multi-inher): Handle lines with
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
422 ;; This kludge is necessary to support both inher-cont and |
b88ff2eabd4e
(c-lineup-multi-inher): Handle lines with
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
423 ;; member-init-cont, since they have different anchor positions. |
b88ff2eabd4e
(c-lineup-multi-inher): Handle lines with
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
424 (c-backward-syntactic-ws) |
b88ff2eabd4e
(c-lineup-multi-inher): Handle lines with
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
425 (when (eq (char-before) ?:) |
b88ff2eabd4e
(c-lineup-multi-inher): Handle lines with
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
426 (backward-char) |
b88ff2eabd4e
(c-lineup-multi-inher): Handle lines with
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
427 (c-backward-syntactic-ws)) |
b88ff2eabd4e
(c-lineup-multi-inher): Handle lines with
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
428 |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
429 (c-syntactic-re-search-forward ":" eol 'move) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
430 (if (looking-at c-syntactic-eol) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
431 (c-forward-syntactic-ws here) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
432 (if (eq char-after-ip ?,) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
433 (backward-char) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
434 (skip-chars-forward " \t" eol))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
435 (if (< (point) here) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
436 (vector (current-column))) |
18720 | 437 ))) |
438 | |
439 (defun c-lineup-java-inher (langelem) | |
26817 | 440 "Line up Java implements and extends declarations. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
441 If class names follow on the same line as the implements/extends |
26817 | 442 keyword, they are lined up under each other. Otherwise, they are |
443 indented by adding `c-basic-offset' to the column of the keyword. | |
444 E.g: | |
445 | |
446 class Foo class Foo | |
447 extends extends Cyphr, | |
448 Bar <-> Bar <- c-lineup-java-inher | |
449 <--> c-basic-offset | |
450 | |
451 Works with: inher-cont." | |
18720 | 452 (save-excursion |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
453 (goto-char (c-langelem-pos langelem)) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
454 (forward-word 1) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
455 (if (looking-at "[ \t]*$") |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
456 c-basic-offset |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
457 (c-forward-syntactic-ws) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
458 (vector (current-column))))) |
18720 | 459 |
460 (defun c-lineup-java-throws (langelem) | |
26817 | 461 "Line up Java throws declarations. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
462 If exception names follow on the same line as the throws keyword, |
26817 | 463 they are lined up under each other. Otherwise, they are indented by |
464 adding `c-basic-offset' to the column of the throws keyword. The | |
465 throws keyword itself is also indented by `c-basic-offset' from the | |
466 function declaration start if it doesn't hang. E.g: | |
467 | |
468 int foo() int foo() throws Cyphr, | |
469 throws <-> Bar, <- c-lineup-java-throws | |
470 Bar <-> Vlod <- c-lineup-java-throws | |
471 <--><--> c-basic-offset | |
472 | |
473 Works with: func-decl-cont." | |
18720 | 474 (save-excursion |
26817 | 475 (let* ((lim (1- (c-point 'bol))) |
476 (throws (catch 'done | |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
477 (goto-char (c-langelem-pos langelem)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
478 (while (zerop (c-forward-token-2 1 t lim)) |
26817 | 479 (if (looking-at "throws\\>[^_]") |
480 (throw 'done t)))))) | |
481 (if throws | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
482 (if (zerop (c-forward-token-2 1 nil (c-point 'eol))) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
483 (vector (current-column)) |
26817 | 484 (back-to-indentation) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
485 (vector (+ (current-column) c-basic-offset))) |
26817 | 486 c-basic-offset)))) |
18720 | 487 |
20911 | 488 (defun c-indent-one-line-block (langelem) |
26817 | 489 "Indent a one line block `c-basic-offset' extra. |
490 E.g: | |
491 | |
492 if (n > 0) if (n > 0) | |
493 {m+=n; n=0;} <-> { <- c-indent-one-line-block | |
494 <--> c-basic-offset m+=n; n=0; | |
495 } | |
496 | |
36920 | 497 The block may use any kind of parenthesis character. nil is returned |
498 if the line doesn't start with a one line block, which makes the | |
499 function usable in list expressions. | |
26817 | 500 |
501 Work with: Almost all syntactic symbols, but most useful on *-open." | |
20911 | 502 (save-excursion |
26817 | 503 (let ((eol (c-point 'eol))) |
504 (back-to-indentation) | |
505 (if (and (eq (char-syntax (char-after)) ?\() | |
24282 | 506 (c-safe (progn (c-forward-sexp) t)) |
26817 | 507 (<= (point) eol)) |
20911 | 508 c-basic-offset |
26817 | 509 nil)))) |
510 | |
511 (defun c-indent-multi-line-block (langelem) | |
512 "Indent a multi line block `c-basic-offset' extra. | |
513 E.g: | |
514 | |
515 int *foo[] = { int *foo[] = { | |
516 NULL, NULL, | |
517 {17}, <-> { <- c-indent-multi-line-block | |
518 17 | |
519 } | |
520 <--> c-basic-offset | |
521 | |
36920 | 522 The block may use any kind of parenthesis character. nil is returned |
523 if the line doesn't start with a multi line block, which makes the | |
524 function usable in list expressions. | |
26817 | 525 |
526 Work with: Almost all syntactic symbols, but most useful on *-open." | |
527 (save-excursion | |
528 (let ((eol (c-point 'eol))) | |
529 (back-to-indentation) | |
530 (if (and (eq (char-syntax (char-after)) ?\() | |
531 (or (not (c-safe (progn (c-forward-sexp) t))) | |
532 (> (point) eol))) | |
533 c-basic-offset | |
534 nil)))) | |
20911 | 535 |
18720 | 536 (defun c-lineup-C-comments (langelem) |
26817 | 537 "Line up C block comment continuation lines. |
36920 | 538 Various heuristics are used to handle many of the common comment |
26817 | 539 styles. Some examples: |
540 | |
541 /* /** /* /* text /* /** | |
542 * text * text text text ** text ** text | |
543 */ */ */ */ */ */ | |
544 | |
545 /********************************************************************* | |
546 * text | |
547 ********************************************************************/ | |
548 | |
549 /********************************************************************* | |
550 Free form text comments: | |
551 In comments with a long delimiter line at the start, the indentation | |
552 is kept unchanged for lines that start with an empty comment line | |
553 prefix. The delimiter line is whatever matches the | |
554 `comment-start-skip' regexp. | |
555 *********************************************************************/ | |
556 | |
557 The variable `c-comment-prefix-regexp' is used to recognize the | |
558 comment line prefix, e.g. the `*' that usually starts every line | |
559 inside a comment. | |
560 | |
561 Works with: The `c' syntactic symbol." | |
18720 | 562 (save-excursion |
26817 | 563 (let* ((here (point)) |
564 (prefixlen (progn (back-to-indentation) | |
36920 | 565 (if (looking-at c-current-comment-prefix) |
26817 | 566 (- (match-end 0) (point)) |
567 0))) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
568 (starterlen |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
569 ;; Get the length of the comment starter, not including |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
570 ;; the first '/'. We check if the comment prefix matched |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
571 ;; on the current line matches the starter or if it |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
572 ;; matches comment-start-skip, and choose whichever is |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
573 ;; longest. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
574 (max (save-excursion |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
575 (goto-char (1+ (c-langelem-pos langelem))) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
576 (if (and (match-string 0) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
577 (looking-at (regexp-quote (match-string 0)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
578 (- (match-end 0) (match-beginning 0)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
579 0)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
580 (save-excursion |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
581 (goto-char (c-langelem-pos langelem)) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
582 (looking-at comment-start-skip) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
583 (- (or (match-end 1) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
584 (save-excursion |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
585 (goto-char (match-end 0)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
586 (skip-chars-backward " \t") |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
587 (point))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
588 (point) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
589 1))))) |
26817 | 590 (if (and (> starterlen 10) (zerop prefixlen)) |
591 ;; The comment has a long starter and the line doesn't have | |
592 ;; a nonempty comment prefix. Treat it as free form text | |
593 ;; and don't change the indentation. | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
594 (vector (current-column)) |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
595 ;; Go back to the previous non-blank line, if any. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
596 (while |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
597 (progn |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
598 (forward-line -1) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
599 (back-to-indentation) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
600 (and (> (point) (c-langelem-pos langelem)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
601 (looking-at "[ \t]*$")))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
602 ;; Is the starting line the first continuation line with content? |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
603 (if (>= (c-langelem-pos langelem) (point)) |
26817 | 604 (if (zerop prefixlen) |
605 ;; No nonempty comment prefix. Align after comment | |
606 ;; starter. | |
18720 | 607 (progn |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
608 (looking-at comment-start-skip) |
26817 | 609 (goto-char (match-end 0)) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
610 ;; The following should not be necessary, since |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
611 ;; comment-start-skip should match everything (i.e. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
612 ;; typically whitespace) that leads up to the text. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
613 ;;(if (looking-at "\\([ \t]+\\).+$") |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
614 ;; ;; Align with the text that hangs after the |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
615 ;; ;; comment starter. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
616 ;; (goto-char (match-end 1))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
617 (vector (current-column))) |
26817 | 618 ;; How long is the comment starter? if greater than the |
619 ;; length of the comment prefix, align left. if less | |
620 ;; than or equal, align right. this should also pick up | |
621 ;; Javadoc style comments. | |
622 (if (> starterlen prefixlen) | |
623 (progn | |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
624 (goto-char (c-langelem-pos langelem)) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
625 (vector (1+ (current-column)))) |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
626 (goto-char (+ (c-langelem-pos langelem) starterlen 1)) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
627 (vector (- (current-column) prefixlen)))) |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
628 ;; We didn't start on the first non-blank continuation line. If the |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
629 ;; previous line has a nonempty comment prefix, align with it. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
630 ;; Otherwise, align with the previous nonempty line, but align the |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
631 ;; comment ender with the starter. |
36920 | 632 (when (or (not (looking-at c-current-comment-prefix)) |
26817 | 633 (eq (match-beginning 0) (match-end 0))) |
634 (goto-char here) | |
635 (back-to-indentation) | |
36920 | 636 (if (looking-at (concat "\\(" c-current-comment-prefix "\\)\\*/")) |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
637 (goto-char (c-langelem-pos langelem)) |
26817 | 638 (while (and (zerop (forward-line -1)) |
639 (looking-at "^[ \t]*$"))) | |
640 (back-to-indentation) | |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
641 (if (< (point) (c-langelem-pos langelem)) |
26817 | 642 ;; Align with the comment starter rather than |
643 ;; with the code before it. | |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
644 (goto-char (c-langelem-pos langelem))))) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
645 (vector (current-column))))))) |
18720 | 646 |
647 (defun c-lineup-comment (langelem) | |
26817 | 648 "Line up a comment start according to `c-comment-only-line-offset'. |
649 If the comment is lined up with a comment starter on the previous | |
650 line, that alignment is preserved. | |
651 | |
652 Works with: comment-intro." | |
18720 | 653 (save-excursion |
654 (back-to-indentation) | |
36920 | 655 (let ((col (current-column))) |
18720 | 656 (cond |
26817 | 657 ;; CASE 1: preserve aligned comments |
658 ((save-excursion | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
659 (and (c-backward-single-comment) |
26817 | 660 (= col (current-column)))) |
36920 | 661 (vector col)) ; Return an absolute column. |
18720 | 662 ;; indent as specified by c-comment-only-line-offset |
663 ((not (bolp)) | |
664 (or (car-safe c-comment-only-line-offset) | |
665 c-comment-only-line-offset)) | |
666 (t | |
667 (or (cdr-safe c-comment-only-line-offset) | |
668 (car-safe c-comment-only-line-offset) | |
669 -1000)) ;jam it against the left side | |
670 )))) | |
671 | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
672 (defun c-lineup-knr-region-comment (langelem) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
673 "Line up a comment in the \"K&R region\" with the declaration. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
674 That is the region between the function or class header and the |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
675 beginning of the block. E.g: |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
676 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
677 int main() |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
678 /* This is the main function. */ <- c-lineup-knr-region-comment |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
679 { |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
680 return 0; |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
681 } |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
682 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
683 Return nil if called in any other situation, to be useful in list |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
684 expressions. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
685 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
686 Works with: comment-intro." |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
687 (when (or (assq 'topmost-intro-cont c-syntactic-context) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
688 (assq 'func-decl-cont c-syntactic-context) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
689 (assq 'knr-argdecl-intro c-syntactic-context) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
690 (assq 'lambda-intro-cont c-syntactic-context)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
691 (save-excursion |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
692 (beginning-of-line) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
693 (c-beginning-of-statement-1) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
694 (vector (current-column))))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
695 |
18720 | 696 (defun c-lineup-runin-statements (langelem) |
26817 | 697 "Line up statements when the first statement is on the same line as |
698 the block opening brace. E.g: | |
699 | |
700 int main() | |
701 { puts (\"Hello world!\"); | |
702 return 0; <- c-lineup-runin-statements | |
703 } | |
704 | |
705 If there is no statement after the opening brace to align with, nil is | |
706 returned. This makes the function usable in list expressions. | |
707 | |
708 Works with: The `statement' syntactic symbol." | |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
709 (if (eq (char-after (c-langelem-pos langelem)) ?{) |
18720 | 710 (save-excursion |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
711 (if (c-langelem-pos langelem) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
712 (goto-char (c-langelem-pos langelem))) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
713 (forward-char 1) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
714 (skip-chars-forward " \t") |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
715 (unless (eolp) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
716 (vector (current-column)))))) |
18720 | 717 |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
718 (defun c-lineup-assignments (langelem) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
719 "Line up the current line after the assignment operator on the first |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
720 line in the statement. If there isn't any, return nil to allow |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
721 stacking with other line-up functions. If the current line contains |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
722 an assignment operator too, try to align it with the first one. |
26817 | 723 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
724 Works with: topmost-intro-cont, statement-cont, arglist-cont, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
725 arglist-cont-nonempty." |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
726 (let (startpos endpos equalp) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
727 |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
728 (if (eq (c-langelem-sym langelem) 'arglist-cont-nonempty) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
729 ;; If it's an arglist-cont-nonempty then we're only interested |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
730 ;; in equal signs outside it. We don't search for a "=" on |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
731 ;; the current line since that'd have a different nesting |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
732 ;; compared to the one we should align with. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
733 (save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
734 (save-restriction |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
735 (setq endpos (c-langelem-2nd-pos c-syntactic-element)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
736 (narrow-to-region (c-langelem-pos langelem) endpos) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
737 (if (setq startpos (c-up-list-backward endpos)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
738 (setq startpos (1+ startpos)) |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
739 (setq startpos (c-langelem-pos langelem))))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
740 |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
741 (setq startpos (c-langelem-pos langelem) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
742 endpos (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
743 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
744 ;; Find a syntactically relevant and unnested "=" token on the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
745 ;; current line. equalp is in that case set to the number of |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
746 ;; columns to left shift the current line to align it with the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
747 ;; goal column. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
748 (save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
749 (beginning-of-line) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
750 (when (c-syntactic-re-search-forward |
52341
6a060e586596
(c-lineup-math): Don't align the operators "!=", "<=" and ">=" as assignment
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
751 c-assignment-op-regexp |
6a060e586596
(c-lineup-math): Don't align the operators "!=", "<=" and ">=" as assignment
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
752 (c-point 'eol) t t t) |
6a060e586596
(c-lineup-math): Don't align the operators "!=", "<=" and ">=" as assignment
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
753 (setq equalp (- (or (match-beginning 1) |
6a060e586596
(c-lineup-math): Don't align the operators "!=", "<=" and ">=" as assignment
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
754 (match-end 0)) |
6a060e586596
(c-lineup-math): Don't align the operators "!=", "<=" and ">=" as assignment
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
755 (c-point 'boi)))))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
756 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
757 (save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
758 (goto-char startpos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
759 (if (or (if (c-syntactic-re-search-forward |
52341
6a060e586596
(c-lineup-math): Don't align the operators "!=", "<=" and ">=" as assignment
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
760 c-assignment-op-regexp |
6a060e586596
(c-lineup-math): Don't align the operators "!=", "<=" and ">=" as assignment
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
761 (min endpos (c-point 'eol)) t t t) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
762 (progn |
52341
6a060e586596
(c-lineup-math): Don't align the operators "!=", "<=" and ">=" as assignment
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
763 (goto-char (or (match-beginning 1) |
6a060e586596
(c-lineup-math): Don't align the operators "!=", "<=" and ">=" as assignment
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
764 (match-end 0))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
765 nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
766 t) |
24282 | 767 (save-excursion |
768 (c-forward-syntactic-ws (c-point 'eol)) | |
769 (eolp))) | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
770 ;; There's no equal sign on the line, or there is one but |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
771 ;; nothing follows it. |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
772 nil |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
773 |
18720 | 774 ;; calculate indentation column after equals and ws, unless |
775 ;; our line contains an equals sign | |
776 (if (not equalp) | |
777 (progn | |
778 (skip-chars-forward " \t") | |
779 (setq equalp 0))) | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
780 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
781 (vector (- (current-column) equalp))) |
18720 | 782 ))) |
783 | |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
784 (defun c-lineup-math (langelem) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
785 "Like `c-lineup-assignments' but indent with `c-basic-offset' if no |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
786 assignment operator was found on the first line. I.e. this function |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
787 is the same as specifying a list (c-lineup-assignments +). It's |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
788 provided for compatibility with old configurations. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
789 |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
790 Works with: topmost-intro-cont, statement-cont, arglist-cont, |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
791 arglist-cont-nonempty." |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
792 (or (c-lineup-assignments langelem) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
793 c-basic-offset)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
794 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
795 (defun c-lineup-cascaded-calls (langelem) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
796 "Line up \"cascaded calls\" under each other. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
797 If the line begins with \"->\" or \".\" and the preceding line ends |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
798 with one or more function calls preceded by the same token, then the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
799 arrow is lined up with the first of those tokens. E.g: |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
800 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
801 result = proc->add(17)->add(18) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
802 ->add(19) + <- c-lineup-cascaded-calls |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
803 offset; <- c-lineup-cascaded-calls (inactive) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
804 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
805 In any other situation nil is returned to allow use in list |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
806 expressions. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
807 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
808 Works with: topmost-intro-cont, statement-cont, arglist-cont, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
809 arglist-cont-nonempty." |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
810 |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
811 (if (and (eq (c-langelem-sym langelem) 'arglist-cont-nonempty) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
812 (not (eq (c-langelem-2nd-pos c-syntactic-element) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
813 (c-most-enclosing-brace (c-parse-state))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
814 ;; The innermost open paren is not our one, so don't do |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
815 ;; anything. This can occur for arglist-cont-nonempty with |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
816 ;; nested arglist starts on the same line. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
817 nil |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
818 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
819 (save-excursion |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
820 (back-to-indentation) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
821 (let ((operator (and (looking-at "->\\|\\.") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
822 (regexp-quote (match-string 0)))) |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
823 (stmt-start (c-langelem-pos langelem)) col) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
824 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
825 (when (and operator |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
826 (looking-at operator) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
827 (zerop (c-backward-token-2 1 t stmt-start)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
828 (eq (char-after) ?\() |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
829 (zerop (c-backward-token-2 2 t stmt-start)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
830 (looking-at operator)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
831 (setq col (current-column)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
832 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
833 (while (and (zerop (c-backward-token-2 1 t stmt-start)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
834 (eq (char-after) ?\() |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
835 (zerop (c-backward-token-2 2 t stmt-start)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
836 (looking-at operator)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
837 (setq col (current-column))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
838 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
839 (vector col)))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
840 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
841 (defun c-lineup-string-cont (langelem) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
842 "Line up a continued string under the one it continues. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
843 A continued string in this sense is where a string literal follows |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
844 directly after another one. E.g: |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
845 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
846 result = prefix + \"A message \" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
847 \"string.\"; <- c-lineup-string-cont |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
848 |
73912
aa069c1a1c03
(c-lineup-string-cont): Improve previous doc fix.
Glenn Morris <rgm@gnu.org>
parents:
73880
diff
changeset
|
849 In other situations, returns nil, to allow stacking with other |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
850 line-up functions. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
851 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
852 Works with: topmost-intro-cont, statement-cont, arglist-cont, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
853 arglist-cont-nonempty." |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
854 (save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
855 (back-to-indentation) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
856 (and (looking-at "\\s\"") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
857 (let ((quote (char-after)) pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
858 (while (and (progn (c-backward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
859 (eq (char-before) quote)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
860 (c-safe (c-backward-sexp) t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
861 (/= (setq pos (point)) (c-point 'boi)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
862 (when pos |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
863 (goto-char pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
864 (vector (current-column))))))) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
865 |
26817 | 866 (defun c-lineup-template-args (langelem) |
867 "Line up template argument lines under the first argument. | |
868 To allow this function to be used in a list expression, nil is | |
869 returned if there's no template argument on the first line. | |
870 | |
871 Works with: template-args-cont." | |
872 (save-excursion | |
873 (c-with-syntax-table c++-template-syntax-table | |
874 (beginning-of-line) | |
875 (backward-up-list 1) | |
876 (if (and (eq (char-after) ?<) | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
877 (zerop (c-forward-token-2 1 nil (c-point 'eol)))) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
878 (vector (current-column)))))) |
26817 | 879 |
18720 | 880 (defun c-lineup-ObjC-method-call (langelem) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
881 "Line up selector args as Emacs Lisp mode does with function args: |
26817 | 882 Go to the position right after the message receiver, and if you are at |
883 the end of the line, indent the current line c-basic-offset columns | |
884 from the opening bracket; otherwise you are looking at the first | |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
885 character of the first method call argument, so line up the current |
26817 | 886 line with it. |
887 | |
888 Works with: objc-method-call-cont." | |
18720 | 889 (save-excursion |
890 (let* ((extra (save-excursion | |
891 (back-to-indentation) | |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
892 (c-backward-syntactic-ws (c-langelem-pos langelem)) |
18720 | 893 (if (eq (char-before) ?:) |
894 (- c-basic-offset) | |
895 0))) | |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
896 (open-bracket-pos (c-langelem-pos langelem)) |
18720 | 897 (open-bracket-col (progn |
898 (goto-char open-bracket-pos) | |
899 (current-column))) | |
900 (target-col (progn | |
901 (forward-char) | |
24282 | 902 (c-forward-sexp) |
18720 | 903 (skip-chars-forward " \t") |
904 (if (eolp) | |
905 (+ open-bracket-col c-basic-offset) | |
906 (current-column)))) | |
907 ) | |
908 (- target-col open-bracket-col extra)))) | |
909 | |
103117
49b361ba00e8
Enhancements for Objective-C:
Alan Mackenzie <acm@muc.de>
parents:
101112
diff
changeset
|
910 (defun c-lineup-ObjC-method-call-colons (langelem) |
49b361ba00e8
Enhancements for Objective-C:
Alan Mackenzie <acm@muc.de>
parents:
101112
diff
changeset
|
911 "Line up selector args as Project Builder / XCode: colons of first |
49b361ba00e8
Enhancements for Objective-C:
Alan Mackenzie <acm@muc.de>
parents:
101112
diff
changeset
|
912 selector portions on successive lines are aligned. If no decision can |
49b361ba00e8
Enhancements for Objective-C:
Alan Mackenzie <acm@muc.de>
parents:
101112
diff
changeset
|
913 be made return NIL, so that other lineup methods can be tried. This is |
49b361ba00e8
Enhancements for Objective-C:
Alan Mackenzie <acm@muc.de>
parents:
101112
diff
changeset
|
914 typically chained with `c-lineup-ObjC-method-call'. |
49b361ba00e8
Enhancements for Objective-C:
Alan Mackenzie <acm@muc.de>
parents:
101112
diff
changeset
|
915 |
49b361ba00e8
Enhancements for Objective-C:
Alan Mackenzie <acm@muc.de>
parents:
101112
diff
changeset
|
916 Works with: objc-method-call-cont." |
49b361ba00e8
Enhancements for Objective-C:
Alan Mackenzie <acm@muc.de>
parents:
101112
diff
changeset
|
917 (save-excursion |
49b361ba00e8
Enhancements for Objective-C:
Alan Mackenzie <acm@muc.de>
parents:
101112
diff
changeset
|
918 (catch 'no-idea |
49b361ba00e8
Enhancements for Objective-C:
Alan Mackenzie <acm@muc.de>
parents:
101112
diff
changeset
|
919 (let* ((method-arg-len (progn |
49b361ba00e8
Enhancements for Objective-C:
Alan Mackenzie <acm@muc.de>
parents:
101112
diff
changeset
|
920 (back-to-indentation) |
49b361ba00e8
Enhancements for Objective-C:
Alan Mackenzie <acm@muc.de>
parents:
101112
diff
changeset
|
921 (if (search-forward ":" (c-point 'eol) 'move) |
49b361ba00e8
Enhancements for Objective-C:
Alan Mackenzie <acm@muc.de>
parents:
101112
diff
changeset
|
922 (- (point) (c-point 'boi)) |
49b361ba00e8
Enhancements for Objective-C:
Alan Mackenzie <acm@muc.de>
parents:
101112
diff
changeset
|
923 ; no complete argument to indent yet |
49b361ba00e8
Enhancements for Objective-C:
Alan Mackenzie <acm@muc.de>
parents:
101112
diff
changeset
|
924 (throw 'no-idea nil)))) |
49b361ba00e8
Enhancements for Objective-C:
Alan Mackenzie <acm@muc.de>
parents:
101112
diff
changeset
|
925 |
49b361ba00e8
Enhancements for Objective-C:
Alan Mackenzie <acm@muc.de>
parents:
101112
diff
changeset
|
926 (extra (save-excursion |
49b361ba00e8
Enhancements for Objective-C:
Alan Mackenzie <acm@muc.de>
parents:
101112
diff
changeset
|
927 ; indent parameter to argument if needed |
49b361ba00e8
Enhancements for Objective-C:
Alan Mackenzie <acm@muc.de>
parents:
101112
diff
changeset
|
928 (back-to-indentation) |
49b361ba00e8
Enhancements for Objective-C:
Alan Mackenzie <acm@muc.de>
parents:
101112
diff
changeset
|
929 (c-backward-syntactic-ws (c-langelem-pos langelem)) |
49b361ba00e8
Enhancements for Objective-C:
Alan Mackenzie <acm@muc.de>
parents:
101112
diff
changeset
|
930 (if (eq ?: (char-before)) |
49b361ba00e8
Enhancements for Objective-C:
Alan Mackenzie <acm@muc.de>
parents:
101112
diff
changeset
|
931 c-objc-method-parameter-offset 0))) |
49b361ba00e8
Enhancements for Objective-C:
Alan Mackenzie <acm@muc.de>
parents:
101112
diff
changeset
|
932 |
49b361ba00e8
Enhancements for Objective-C:
Alan Mackenzie <acm@muc.de>
parents:
101112
diff
changeset
|
933 (open-bracket-col (c-langelem-col langelem)) |
49b361ba00e8
Enhancements for Objective-C:
Alan Mackenzie <acm@muc.de>
parents:
101112
diff
changeset
|
934 |
49b361ba00e8
Enhancements for Objective-C:
Alan Mackenzie <acm@muc.de>
parents:
101112
diff
changeset
|
935 (arg-ralign-colon-ofs (progn |
49b361ba00e8
Enhancements for Objective-C:
Alan Mackenzie <acm@muc.de>
parents:
101112
diff
changeset
|
936 (forward-char) ; skip over '[' |
49b361ba00e8
Enhancements for Objective-C:
Alan Mackenzie <acm@muc.de>
parents:
101112
diff
changeset
|
937 ; skip over object/class name |
49b361ba00e8
Enhancements for Objective-C:
Alan Mackenzie <acm@muc.de>
parents:
101112
diff
changeset
|
938 ; and first argument |
49b361ba00e8
Enhancements for Objective-C:
Alan Mackenzie <acm@muc.de>
parents:
101112
diff
changeset
|
939 (c-forward-sexp 2) |
49b361ba00e8
Enhancements for Objective-C:
Alan Mackenzie <acm@muc.de>
parents:
101112
diff
changeset
|
940 (if (search-forward ":" (c-point 'eol) 'move) |
49b361ba00e8
Enhancements for Objective-C:
Alan Mackenzie <acm@muc.de>
parents:
101112
diff
changeset
|
941 (- (current-column) open-bracket-col |
49b361ba00e8
Enhancements for Objective-C:
Alan Mackenzie <acm@muc.de>
parents:
101112
diff
changeset
|
942 method-arg-len extra) |
49b361ba00e8
Enhancements for Objective-C:
Alan Mackenzie <acm@muc.de>
parents:
101112
diff
changeset
|
943 ; previous arg has no param |
49b361ba00e8
Enhancements for Objective-C:
Alan Mackenzie <acm@muc.de>
parents:
101112
diff
changeset
|
944 c-objc-method-arg-unfinished-offset)))) |
49b361ba00e8
Enhancements for Objective-C:
Alan Mackenzie <acm@muc.de>
parents:
101112
diff
changeset
|
945 |
49b361ba00e8
Enhancements for Objective-C:
Alan Mackenzie <acm@muc.de>
parents:
101112
diff
changeset
|
946 (if (>= arg-ralign-colon-ofs c-objc-method-arg-min-delta-to-bracket) |
49b361ba00e8
Enhancements for Objective-C:
Alan Mackenzie <acm@muc.de>
parents:
101112
diff
changeset
|
947 (+ arg-ralign-colon-ofs extra) |
49b361ba00e8
Enhancements for Objective-C:
Alan Mackenzie <acm@muc.de>
parents:
101112
diff
changeset
|
948 (throw 'no-idea nil)))))) |
49b361ba00e8
Enhancements for Objective-C:
Alan Mackenzie <acm@muc.de>
parents:
101112
diff
changeset
|
949 |
18720 | 950 (defun c-lineup-ObjC-method-args (langelem) |
103117
49b361ba00e8
Enhancements for Objective-C:
Alan Mackenzie <acm@muc.de>
parents:
101112
diff
changeset
|
951 "Line up the colons that separate args in a method declaration. |
26817 | 952 The colon on the current line is aligned with the one on the first |
953 line. | |
954 | |
955 Works with: objc-method-args-cont." | |
18720 | 956 (save-excursion |
957 (let* ((here (c-point 'boi)) | |
958 (curcol (progn (goto-char here) (current-column))) | |
959 (eol (c-point 'eol)) | |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
960 (relpos (c-langelem-pos langelem)) |
18720 | 961 (first-col-column (progn |
962 (goto-char relpos) | |
963 (skip-chars-forward "^:" eol) | |
964 (and (eq (char-after) ?:) | |
965 (current-column))))) | |
966 (if (not first-col-column) | |
967 c-basic-offset | |
968 (goto-char here) | |
969 (skip-chars-forward "^:" eol) | |
970 (if (eq (char-after) ?:) | |
971 (+ curcol (- first-col-column (current-column))) | |
972 c-basic-offset))))) | |
973 | |
974 (defun c-lineup-ObjC-method-args-2 (langelem) | |
103117
49b361ba00e8
Enhancements for Objective-C:
Alan Mackenzie <acm@muc.de>
parents:
101112
diff
changeset
|
975 "Line up the colons that separate args in a method declaration. |
26817 | 976 The colon on the current line is aligned with the one on the previous |
977 line. | |
978 | |
979 Works with: objc-method-args-cont." | |
18720 | 980 (save-excursion |
981 (let* ((here (c-point 'boi)) | |
982 (curcol (progn (goto-char here) (current-column))) | |
983 (eol (c-point 'eol)) | |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
984 (relpos (c-langelem-pos langelem)) |
18720 | 985 (prev-col-column (progn |
986 (skip-chars-backward "^:" relpos) | |
987 (and (eq (char-before) ?:) | |
988 (- (current-column) 1))))) | |
989 (if (not prev-col-column) | |
990 c-basic-offset | |
991 (goto-char here) | |
992 (skip-chars-forward "^:" eol) | |
993 (if (eq (char-after) ?:) | |
994 (+ curcol (- prev-col-column (current-column))) | |
995 c-basic-offset))))) | |
996 | |
24282 | 997 (defun c-lineup-inexpr-block (langelem) |
26817 | 998 "Line up the block for constructs that use a block inside an expression, |
999 e.g. anonymous classes in Java and lambda functions in Pike. The body | |
1000 is aligned with the start of the header, e.g. with the \"new\" or | |
1001 \"lambda\" keyword. Returns nil if the block isn't part of such a | |
1002 construct. | |
1003 | |
1004 Works with: inlambda, inexpr-statement, inexpr-class." | |
24282 | 1005 (save-excursion |
1006 (back-to-indentation) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1007 (let* ((paren-state (c-parse-state)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1008 (containing-sexp (c-most-enclosing-brace paren-state)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1009 (res (or (c-looking-at-inexpr-block |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1010 (c-safe-position containing-sexp paren-state) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1011 containing-sexp) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1012 (and containing-sexp |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1013 (progn (goto-char containing-sexp) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1014 (eq (char-after) ?{)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1015 (progn (setq containing-sexp |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1016 (c-most-enclosing-brace paren-state |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1017 (point))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1018 (c-looking-at-inexpr-block |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1019 (c-safe-position containing-sexp paren-state) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1020 containing-sexp)))))) |
26817 | 1021 (when res |
24282 | 1022 (goto-char (cdr res)) |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1023 (vector (current-column)))))) |
24282 | 1024 |
26817 | 1025 (defun c-lineup-whitesmith-in-block (langelem) |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1026 "Line up lines inside a block in Whitesmith style. |
26817 | 1027 It's done in a way that works both when the opening brace hangs and |
1028 when it doesn't. E.g: | |
1029 | |
1030 something | |
1031 { something { | |
1032 foo; <-> foo; <- c-lineup-whitesmith-in-block | |
1033 } } | |
1034 <--> c-basic-offset | |
1035 | |
1036 In the first case the indentation is kept unchanged, in the | |
1037 second `c-basic-offset' is added. | |
1038 | |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1039 Works with: defun-close, defun-block-intro, inline-close, block-close, |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1040 brace-list-close, brace-list-intro, statement-block-intro, |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1041 arglist-intro, arglist-cont-nonempty, arglist-close, and all in* |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
1042 symbols, e.g. inclass and inextern-lang." |
26817 | 1043 (save-excursion |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1044 (if (and (c-go-up-list-backward) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1045 (= (point) (c-point 'boi))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1046 nil |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1047 c-basic-offset))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1048 |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1049 (defun c-lineup-after-whitesmith-blocks (langelem) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1050 "Compensate for Whitesmith style indentation of blocks. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1051 Due to the way CC Mode calculates anchor positions for normal lines |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1052 inside blocks, this function is necessary for those lines to get |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1053 correct Whitesmith style indentation. Consider the following |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1054 examples: |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1055 |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1056 int foo() |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1057 { |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1058 int foo() { |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1059 { a; |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1060 a; } |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1061 x; <-> x; <- c-lineup-after-whitesmith-blocks |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1062 |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1063 The fact that the line with \"x\" is preceded by a Whitesmith style |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1064 indented block in one case and not the other should not affect its |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1065 indentation. But since CC Mode in cases like this uses the |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1066 indentation of the preceding statement as anchor position, the \"x\" |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1067 would in the rightmost case be indented too much if the offset for |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1068 `statement' was set simply to zero. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1069 |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1070 This lineup function corrects for this situation by detecting if the |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1071 anchor position is at an open paren character. In that case, it |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1072 instead indents relative to the surrounding block just like |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1073 `c-lineup-whitesmith-in-block'. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1074 |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1075 Works with: brace-list-entry, brace-entry-open, statement, |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1076 arglist-cont." |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1077 (save-excursion |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1078 (goto-char (c-langelem-pos langelem)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1079 (when (looking-at "\\s\(") |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1080 (if (c-go-up-list-backward) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1081 (let ((pos (point))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1082 (back-to-indentation) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1083 (if (= pos (point)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1084 (vector (current-column)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1085 (vector (+ (current-column) c-basic-offset)))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1086 (vector 0))))) |
26817 | 1087 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1088 (defun c-lineup-cpp-define (langelem) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1089 "Line up macro continuation lines according to the indentation of |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1090 the construct preceding the macro. E.g: |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1091 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1092 v beg of preceding constr v beg of preceding constr |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1093 int dribble() { |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1094 const char msg[] = if (!running) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1095 \"Some text.\"; error(\"Not running!\"); |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1096 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1097 #define X(A, B) \ #define X(A, B) \ |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1098 do { \ <-> do { \ <- c-lineup-cpp-define |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1099 printf (A, B); \ printf (A, B); \ |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1100 } while (0) } while (0) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1101 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1102 If `c-syntactic-indentation-in-macros' is non-nil, the function |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1103 returns the relative indentation to the macro start line to allow |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1104 accumulation with other offsets. E.g. in the following cases, |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1105 cpp-define-intro is combined with the statement-block-intro that comes |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1106 from the \"do {\" that hangs on the \"#define\" line: |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1107 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1108 int dribble() { |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1109 const char msg[] = if (!running) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1110 \"Some text.\"; error(\"Not running!\"); |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1111 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1112 #define X(A, B) do { \ #define X(A, B) do { \ |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1113 printf (A, B); \ <-> printf (A, B); \ <- c-lineup-cpp-define |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1114 this->refs++; \ this->refs++; \ |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1115 } while (0) <-> } while (0) <- c-lineup-cpp-define |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1116 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1117 The relative indentation returned by `c-lineup-cpp-define' is zero and |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
1118 two, respectively, in these two examples. They are then added to the |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1119 two column indentation that statement-block-intro gives in both cases |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1120 here. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1121 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1122 If the relative indentation is zero, then nil is returned instead. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
1123 That is useful in a list expression to specify the default indentation |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
1124 on the top level. |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1125 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1126 If `c-syntactic-indentation-in-macros' is nil then this function keeps |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1127 the current indentation, except for empty lines \(ignoring the ending |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1128 backslash) where it takes the indentation from the closest preceding |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1129 nonempty line in the macro. If there's no such line in the macro then |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1130 the indentation is taken from the construct preceding it, as described |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1131 above. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1132 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1133 Works with: cpp-define-intro." |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1134 (let (offset) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1135 (if c-syntactic-indentation-in-macros |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1136 ;; Go to the macro start and do a syntactic analysis of it. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1137 ;; Then remove the cpp-macro element it should contain and |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1138 ;; calculate the indentation it then would get. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1139 (save-excursion |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1140 (c-beginning-of-macro) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1141 (setq offset (- (c-get-syntactic-indentation |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1142 (delete '(cpp-macro) (c-guess-basic-syntax))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1143 (save-excursion |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1144 (back-to-indentation) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1145 (current-column)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1146 (if (zerop offset) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1147 nil |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1148 offset)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1149 ;; Do not indent syntactically inside the macro. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1150 (save-excursion |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1151 (let ((macro-start-line (save-excursion |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1152 (goto-char (c-query-macro-start)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1153 (beginning-of-line) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1154 (point)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1155 (beginning-of-line) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1156 ;; Check every line while inside the macro. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1157 (while (and (> (point) macro-start-line) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1158 (looking-at "[ \t]*\\\\?$") |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1159 (= (forward-line -1) 0))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1160 (if (<= (point) macro-start-line) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1161 ;; If we've stepped out of the macro we take the |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1162 ;; syntactic offset. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1163 (setq offset (c-get-syntactic-indentation |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1164 (delete '(cpp-macro) (c-guess-basic-syntax)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1165 (setq offset (current-indentation))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1166 (if (zerop offset) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1167 nil |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1168 (vector offset))))))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1169 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1170 ;; Contributed by Kevin Ryde <user42@zip.com.au>. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1171 (defun c-lineup-gcc-asm-reg (elem) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1172 "Line up a gcc asm register under one on a previous line. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1173 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1174 asm (\"foo %1, %0\\n\" |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1175 \"bar %0, %1\" |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1176 : \"=r\" (w), |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1177 \"=r\" (x) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1178 : \"0\" (y), |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1179 \"1\" (z)); |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1180 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1181 The \"x\" line is aligned to the text after the \":\" on the \"w\" line, and |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1182 similarly \"z\" under \"y\". |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1183 |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1184 This is done only in an \"asm\" or \"__asm__\" block, and only to |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1185 those lines mentioned. Anywhere else nil is returned. The usual |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1186 arrangement is to have this routine as an extra feature at the start |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1187 of arglist line-ups, e.g. |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1188 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1189 (c-lineup-gcc-asm-reg c-lineup-arglist) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1190 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1191 Works with: arglist-cont, arglist-cont-nonempty." |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1192 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1193 (let ((orig-pos (point)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1194 alignto) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1195 (save-excursion |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1196 (and |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1197 c-opt-asm-stmt-key |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1198 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
1199 ;; Don't do anything if the innermost open paren isn't our one. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
1200 ;; This can occur for arglist-cont-nonempty with nested arglist |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
1201 ;; starts on the same line. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
1202 (or (not (eq (car elem) 'arglist-cont-nonempty)) |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1203 (eq (c-langelem-2nd-pos c-syntactic-element) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
1204 (c-most-enclosing-brace (c-parse-state)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
1205 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1206 ;; Find the ":" to align to. Look for this first so as to quickly |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1207 ;; eliminate pretty much all cases which are not for us. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1208 (re-search-backward "^[ \t]*:[ \t]*\\(.\\)?" (cdr elem) t) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1209 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1210 ;; Must have something after the ":". |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1211 (setq alignto (match-beginning 1)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1212 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1213 ;; Don't touch ":" lines themselves. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1214 (progn (goto-char orig-pos) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1215 (beginning-of-line) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1216 (not (looking-at "^[ \t]*:"))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1217 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1218 ;; Only operate in an asm statement. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1219 (progn (goto-char orig-pos) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1220 (c-in-gcc-asm-p)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1221 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1222 (vector (progn (goto-char alignto) (current-column))))))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
1223 |
20911 | 1224 (defun c-lineup-dont-change (langelem) |
26817 | 1225 "Do not change the indentation of the current line. |
1226 | |
1227 Works with: Any syntactic symbol." | |
20911 | 1228 (save-excursion |
1229 (back-to-indentation) | |
36920 | 1230 (vector (current-column)))) |
20911 | 1231 |
1232 | |
18720 | 1233 (defun c-snug-do-while (syntax pos) |
1234 "Dynamically calculate brace hanginess for do-while statements. | |
1235 Using this function, `while' clauses that end a `do-while' block will | |
1236 remain on the same line as the brace that closes that block. | |
1237 | |
1238 See `c-hanging-braces-alist' for how to utilize this function as an | |
1239 ACTION associated with `block-close' syntax." | |
1240 (save-excursion | |
1241 (let (langelem) | |
1242 (if (and (eq syntax 'block-close) | |
1243 (setq langelem (assq 'block-close c-syntactic-context)) | |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1244 (progn (goto-char (c-langelem-pos langelem)) |
18720 | 1245 (if (eq (char-after) ?{) |
24282 | 1246 (c-safe (c-forward-sexp -1))) |
18720 | 1247 (looking-at "\\<do\\>[^_]"))) |
1248 '(before) | |
1249 '(before after))))) | |
1250 | |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1251 (defun c-snug-1line-defun-close (syntax pos) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1252 "Determine the brace hanginess for an AWK defun-close. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1253 If the action/function being closed is a one-liner, keep it so. Otherwise put |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1254 the closing brace on its own line." |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1255 (save-excursion |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1256 (goto-char pos) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1257 (if (> (c-point 'bol) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1258 (progn (up-list -1) (point))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1259 '(before after) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1260 '(after)))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
1261 |
18720 | 1262 (defun c-gnu-impose-minimum () |
53073
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
1263 "Imposes a minimum indentation for lines inside code blocks. |
18720 | 1264 The variable `c-label-minimum-indentation' specifies the minimum |
1265 indentation amount." | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50860
diff
changeset
|
1266 |
53073
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
1267 (when (and (not |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
1268 ;; Don't adjust macro or comment-only lines. |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
1269 (or (assq 'cpp-macro c-syntactic-context) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
1270 (assq 'comment-intro c-syntactic-context))) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
1271 (c-intersect-lists c-inside-block-syms c-syntactic-context) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
1272 (save-excursion |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
1273 (back-to-indentation) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
1274 (< (current-column) c-label-minimum-indentation))) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
1275 (c-shift-line-indentation (- c-label-minimum-indentation |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
1276 (current-indentation))))) |
18720 | 1277 |
1278 | |
1279 ;; Useful for c-hanging-semi&comma-criteria | |
26817 | 1280 |
18720 | 1281 (defun c-semi&comma-inside-parenlist () |
20911 | 1282 "Controls newline insertion after semicolons in parenthesis lists. |
18720 | 1283 If a comma was inserted, no determination is made. If a semicolon was |
1284 inserted inside a parenthesis list, no newline is added otherwise a | |
1285 newline is added. In either case, checking is stopped. This supports | |
1286 exactly the old newline insertion behavior." | |
1287 ;; newline only after semicolon, but only if that semicolon is not | |
1288 ;; inside a parenthesis list (e.g. a for loop statement) | |
101002
3b3c7e10cd97
Replace last-command-char with last-command-event.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
1289 (if (not (eq last-command-event ?\;)) |
18720 | 1290 nil ; continue checking |
1291 (if (condition-case nil | |
1292 (save-excursion | |
1293 (up-list -1) | |
1294 (not (eq (char-after) ?\())) | |
1295 (error t)) | |
1296 t | |
1297 'stop))) | |
1298 | |
20911 | 1299 ;; Suppresses newlines before non-blank lines |
1300 (defun c-semi&comma-no-newlines-before-nonblanks () | |
1301 "Controls newline insertion after semicolons. | |
1302 If a comma was inserted, no determination is made. If a semicolon was | |
1303 inserted, and the following line is not blank, no newline is inserted. | |
1304 Otherwise, no determination is made." | |
1305 (save-excursion | |
101002
3b3c7e10cd97
Replace last-command-char with last-command-event.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
1306 (if (and (= last-command-event ?\;) |
20911 | 1307 ;;(/= (point-max) |
1308 ;; (save-excursion (skip-syntax-forward " ") (point)) | |
1309 (zerop (forward-line 1)) | |
62641
27b53b1903b6
2005-05-23 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
56646
diff
changeset
|
1310 (bolp) ; forward-line has funny behavior at eob. |
20911 | 1311 (not (looking-at "^[ \t]*$"))) |
1312 'stop | |
1313 nil))) | |
1314 | |
1315 ;; Suppresses new lines after semicolons in one-liners methods | |
1316 (defun c-semi&comma-no-newlines-for-oneline-inliners () | |
1317 "Controls newline insertion after semicolons for some one-line methods. | |
1318 If a comma was inserted, no determination is made. Newlines are | |
1319 suppressed in one-liners, if the line is an in-class inline function. | |
1320 For other semicolon contexts, no determination is made." | |
1321 (let ((syntax (c-guess-basic-syntax)) | |
1322 (bol (save-excursion | |
1323 (if (c-safe (up-list -1) t) | |
1324 (c-point 'bol) | |
1325 -1)))) | |
101002
3b3c7e10cd97
Replace last-command-char with last-command-event.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
1326 (if (and (eq last-command-event ?\;) |
20911 | 1327 (eq (car (car syntax)) 'inclass) |
1328 (eq (car (car (cdr syntax))) 'topmost-intro) | |
1329 (= (c-point 'bol) bol)) | |
1330 'stop | |
1331 nil))) | |
1332 | |
18720 | 1333 |
36920 | 1334 (cc-provide 'cc-align) |
38422
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
36920
diff
changeset
|
1335 |
93975
1e3a407766b9
Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79717
diff
changeset
|
1336 ;; arch-tag: 4d71ed28-bf51-4509-a148-f39669669a2e |
18720 | 1337 ;;; cc-align.el ends here |