aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1995-03-27 07:50:26 +0000
committerRichard M. Stallman1995-03-27 07:50:26 +0000
commitfe7ad22dc13c0842d5e11af7a46f9fd040c24cef (patch)
tree642fc6b47d971b00b14013ea4c1740901eb1960b
parentdd26ab75c7cb7bc0a9b1db2a0216cd8e673d2023 (diff)
downloademacs-fe7ad22dc13c0842d5e11af7a46f9fd040c24cef.tar.gz
emacs-fe7ad22dc13c0842d5e11af7a46f9fd040c24cef.zip
(calculate-c++-indent): Copy colon-line-end code from calculate-c-indent.
-rw-r--r--lisp/progmodes/cplus-md.el51
1 files changed, 31 insertions, 20 deletions
diff --git a/lisp/progmodes/cplus-md.el b/lisp/progmodes/cplus-md.el
index 65ab5967a9b..3d1173959c0 100644
--- a/lisp/progmodes/cplus-md.el
+++ b/lisp/progmodes/cplus-md.el
@@ -529,26 +529,37 @@ Returns nil if line starts inside a string, t if in a comment."
529 ;; If no, find that first statement and indent like it. 529 ;; If no, find that first statement and indent like it.
530 (save-excursion 530 (save-excursion
531 (forward-char 1) 531 (forward-char 1)
532 (while (progn (skip-chars-forward " \t\n") 532 (let ((colon-line-end 0))
533 (looking-at 533 (while (progn (skip-chars-forward " \t\n")
534 (concat 534 (looking-at
535 "#\\|/\\*\\|//" 535 (concat
536 "\\|case[ \t]" 536 "#\\|/\\*\\|//"
537 "\\|[a-zA-Z0-9_$]*:[^:]" 537 "\\|case[ \t]"
538 "\\|friend[ \t]"))) 538 "\\|[a-zA-Z0-9_$]*:[^:]"
539 ;; Skip over comments and labels following openbrace. 539 "\\|friend[ \t]")))
540 (cond ((= (following-char) ?\#) 540 ;; Skip over comments and labels following openbrace.
541 (forward-line 1)) 541 (cond ((= (following-char) ?\#)
542 ((looking-at "/\\*") 542 (forward-line 1))
543 (search-forward "*/" nil 'move)) 543 ((looking-at "/\\*")
544 ((looking-at "//\\|friend[ \t]") 544 (search-forward "*/" nil 'move))
545 (forward-line 1)) 545 ((looking-at "//\\|friend[ \t]")
546 (t 546 (forward-line 1))
547 (re-search-forward ":[^:]" nil 'move)))) 547 (t
548 ;; The first following code counts 548 (save-excursion (end-of-line)
549 ;; if it is before the line we want to indent. 549 (setq colon-line-end (point)))
550 (and (< (point) indent-point) 550 (search-forward ":"))))
551 (current-column))) 551 ;; The first following code counts
552 ;; if it is before the line we want to indent.
553 (and (< (point) indent-point)
554 (-
555 (if (> colon-line-end (point))
556 (- (current-indentation) c-label-offset)
557 (current-column))
558 ;; If prev stmt starts with open-brace, that
559 ;; open brace was offset by c-brace-offset.
560 ;; Compensate to get the column where
561 ;; an ordinary statement would start.
562 (if (= (following-char) ?\{) c-brace-offset 0)))))
552 ;; If no previous statement, 563 ;; If no previous statement,
553 ;; indent it relative to line brace is on. 564 ;; indent it relative to line brace is on.
554 ;; For open brace in column zero, don't let statement 565 ;; For open brace in column zero, don't let statement