Mercurial > emacs
comparison lisp/progmodes/cplus-md.el @ 5300:954744cd720f
(c++-indent-line, calculate-c++-indent):
(indent-c++-exp): Recognize `friend' without `class'.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Thu, 23 Dec 1993 04:41:41 +0000 |
parents | 7775929411c1 |
children | 334f7ce7c8db |
comparison
equal
deleted
inserted
replaced
5299:883c241eed1b | 5300:954744cd720f |
---|---|
45 ;; Sept, 1989 (Glen Ditchfield, gjditchfield@violet.uwaterloo.ca): | 45 ;; Sept, 1989 (Glen Ditchfield, gjditchfield@violet.uwaterloo.ca): |
46 ;; Textual changes to more closely imitate Emacs 18.55's c-mode. | 46 ;; Textual changes to more closely imitate Emacs 18.55's c-mode. |
47 ;; Fixed handling of "default:", where ":" was the last character in the | 47 ;; Fixed handling of "default:", where ":" was the last character in the |
48 ;; buffer. Fixed indentation of comments starting in column 0, and when | 48 ;; buffer. Fixed indentation of comments starting in column 0, and when |
49 ;; previous line contained more than one comment start string. Fixed | 49 ;; previous line contained more than one comment start string. Fixed |
50 ;; handling of "friend class". | 50 ;; handling of "friend". |
51 ;; | 51 ;; |
52 ;; Aug 7, 1989; John Hagerman (hagerman@ece.cmu.edu): | 52 ;; Aug 7, 1989; John Hagerman (hagerman@ece.cmu.edu): |
53 ;; Changed calculate-c++-indent to handle member initializations | 53 ;; Changed calculate-c++-indent to handle member initializations |
54 ;; more flexibly. Two new variables are used to control behavior: | 54 ;; more flexibly. Two new variables are used to control behavior: |
55 ;; c++-member-init-indent and c++-continued-member-init-offset. | 55 ;; c++-member-init-indent and c++-continued-member-init-offset. |
132 nil means to align with previous initializations rather than | 132 nil means to align with previous initializations rather than |
133 with the colon on the first line.") | 133 with the colon on the first line.") |
134 (defvar c++-member-init-indent 0 | 134 (defvar c++-member-init-indent 0 |
135 "*Indentation level of member initializations in function declarations.") | 135 "*Indentation level of member initializations in function declarations.") |
136 (defvar c++-friend-offset -4 | 136 (defvar c++-friend-offset -4 |
137 "*Offset of C++ friend class declarations relative to member declarations.") | 137 "*Offset of C++ friend declarations relative to member declarations.") |
138 (defvar c++-electric-colon t | 138 (defvar c++-electric-colon t |
139 "*If t, colon is an electric terminator.") | 139 "*If t, colon is an electric terminator.") |
140 (defvar c++-empty-arglist-indent nil | 140 (defvar c++-empty-arglist-indent nil |
141 "*Indicates how far to indent an line following an empty argument | 141 "*Indicates how far to indent an line following an empty argument |
142 list. Nil indicates to just after the paren.") | 142 list. Nil indicates to just after the paren.") |
185 c++-empty-arglist-indent | 185 c++-empty-arglist-indent |
186 If non-nil, a function declaration or invocation which ends a line with a | 186 If non-nil, a function declaration or invocation which ends a line with a |
187 left paren is indented this many extra spaces, instead of flush with the | 187 left paren is indented this many extra spaces, instead of flush with the |
188 left paren. | 188 left paren. |
189 c++-friend-offset | 189 c++-friend-offset |
190 Offset of C++ friend class declarations relative to member declarations. | 190 Offset of C++ friend declarations relative to member declarations. |
191 c++-member-init-indent | 191 c++-member-init-indent |
192 Indentation level of member initializations in function declarations, | 192 Indentation level of member initializations in function declarations, |
193 if they are on a separate line beginning with a colon. | 193 if they are on a separate line beginning with a colon. |
194 c++-continued-member-init-offset | 194 c++-continued-member-init-offset |
195 Extra indentation for continuation lines of member initializations; NIL | 195 Extra indentation for continuation lines of member initializations; NIL |
397 ((and (looking-at "else\\b") | 397 ((and (looking-at "else\\b") |
398 (not (looking-at "else\\s_"))) | 398 (not (looking-at "else\\s_"))) |
399 (setq indent (save-excursion | 399 (setq indent (save-excursion |
400 (c-backward-to-start-of-if) | 400 (c-backward-to-start-of-if) |
401 (current-indentation)))) | 401 (current-indentation)))) |
402 ((looking-at "friend\[ \t]class[ \t]") | 402 ((looking-at "friend\[ \t]") |
403 (setq indent (+ indent c++-friend-offset))) | 403 (setq indent (+ indent c++-friend-offset))) |
404 ((= (following-char) ?}) | 404 ((= (following-char) ?}) |
405 (setq indent (- indent c-indent-level))) | 405 (setq indent (- indent c-indent-level))) |
406 ((= (following-char) ?{) | 406 ((= (following-char) ?{) |
407 (setq indent (+ indent c-brace-offset)))))) | 407 (setq indent (+ indent c-brace-offset)))))) |
532 (looking-at | 532 (looking-at |
533 (concat | 533 (concat |
534 "#\\|/\\*\\|//" | 534 "#\\|/\\*\\|//" |
535 "\\|case[ \t]" | 535 "\\|case[ \t]" |
536 "\\|[a-zA-Z0-9_$]*:[^:]" | 536 "\\|[a-zA-Z0-9_$]*:[^:]" |
537 "\\|friend[ \t]class[ \t]"))) | 537 "\\|friend[ \t]"))) |
538 ;; Skip over comments and labels following openbrace. | 538 ;; Skip over comments and labels following openbrace. |
539 (cond ((= (following-char) ?\#) | 539 (cond ((= (following-char) ?\#) |
540 (forward-line 1)) | 540 (forward-line 1)) |
541 ((looking-at "/\\*") | 541 ((looking-at "/\\*") |
542 (search-forward "*/" nil 'move)) | 542 (search-forward "*/" nil 'move)) |
543 ((looking-at "//\\|friend[ \t]class[ \t]") | 543 ((looking-at "//\\|friend[ \t]") |
544 (forward-line 1)) | 544 (forward-line 1)) |
545 (t | 545 (t |
546 (re-search-forward ":[^:]" nil 'move)))) | 546 (re-search-forward ":[^:]" nil 'move)))) |
547 ;; The first following code counts | 547 ;; The first following code counts |
548 ;; if it is before the line we want to indent. | 548 ;; if it is before the line we want to indent. |
698 (and (looking-at "[A-Za-z]") | 698 (and (looking-at "[A-Za-z]") |
699 (save-excursion | 699 (save-excursion |
700 (forward-sexp 1) | 700 (forward-sexp 1) |
701 (looking-at ":[^:]")))) | 701 (looking-at ":[^:]")))) |
702 (setq this-indent (max 1 (+ this-indent c-label-offset)))) | 702 (setq this-indent (max 1 (+ this-indent c-label-offset)))) |
703 (if (looking-at "friend[ \t]class[ \t]") | 703 (if (looking-at "friend[ \t]") |
704 (setq this-indent (+ this-indent c++-friend-offset))) | 704 (setq this-indent (+ this-indent c++-friend-offset))) |
705 (if (= (following-char) ?\}) | 705 (if (= (following-char) ?\}) |
706 (setq this-indent (- this-indent c-indent-level))) | 706 (setq this-indent (- this-indent c-indent-level))) |
707 (if (= (following-char) ?\{) | 707 (if (= (following-char) ?\{) |
708 (setq this-indent (+ this-indent c-brace-offset))) | 708 (setq this-indent (+ this-indent c-brace-offset))) |