aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/progmodes/cc-cmds.el61
1 files changed, 36 insertions, 25 deletions
diff --git a/lisp/progmodes/cc-cmds.el b/lisp/progmodes/cc-cmds.el
index 2f4780306f0..5f667e54e2f 100644
--- a/lisp/progmodes/cc-cmds.el
+++ b/lisp/progmodes/cc-cmds.el
@@ -7,7 +7,7 @@
7;; 1985 Richard M. Stallman 7;; 1985 Richard M. Stallman
8;; Maintainer: cc-mode-help@python.org 8;; Maintainer: cc-mode-help@python.org
9;; Created: 22-Apr-1997 (split from cc-mode.el) 9;; Created: 22-Apr-1997 (split from cc-mode.el)
10;; Version: 5.16 10;; Version: 5.17
11;; Keywords: c languages oop 11;; Keywords: c languages oop
12 12
13;; This file is part of GNU Emacs. 13;; This file is part of GNU Emacs.
@@ -617,11 +617,17 @@ comment."
617 (if (and sentence-flag 617 (if (and sentence-flag
618 (or (nth 3 state) 618 (or (nth 3 state)
619 (nth 4 state) 619 (nth 4 state)
620; (looking-at (concat "[ \t]*" comment-start-skip)) 620 ;; skipping forward into a comment?
621 (save-excursion 621 (and (> 0 count)
622 (skip-chars-backward " \t") 622 (save-excursion
623 (goto-char (- (point) 2)) 623 (skip-chars-forward " \t\n")
624 (looking-at "\\*/")))) 624 (or (eobp)
625 (looking-at comment-start-skip))))
626 (and (< 0 count)
627 (save-excursion
628 (skip-chars-backward " \t\n")
629 (goto-char (- (point) 2))
630 (looking-at "\\*/")))))
625 (forward-sentence (- count)) 631 (forward-sentence (- count))
626 (while (> count 0) 632 (while (> count 0)
627 (c-beginning-of-statement-1 lim) 633 (c-beginning-of-statement-1 lim)
@@ -747,28 +753,33 @@ comment."
747 comment-column)) 753 comment-column))
748 ))))) 754 )))))
749 755
756
750;; for proposed new variable comment-line-break-function 757;; for proposed new variable comment-line-break-function
751(defun c-comment-line-break-function (&optional soft) 758(defun c-comment-line-break-function (&optional soft)
752 ;; we currently don't do anything with soft line breaks 759 ;; we currently don't do anything with soft line breaks
753 (if (or (not c-comment-continuation-stars) 760 (let ((literal (c-in-literal)))
754 (not (c-in-literal))) 761 (cond
755 (indent-new-comment-line soft) 762 ((eq literal 'string))
756 (let ((here (point)) 763 ((or (not c-comment-continuation-stars)
757 (leader c-comment-continuation-stars)) 764 (not literal))
758 (back-to-indentation) 765 (indent-new-comment-line soft))
759 ;; are we looking at a block or lines style comment? 766 (t (let ((here (point))
760 (if (and (looking-at (concat "\\(" c-comment-start-regexp "\\)[ \t]+")) 767 (leader c-comment-continuation-stars))
761 (string-equal (match-string 1) "//")) 768 (back-to-indentation)
762 ;; line style 769 ;; are we looking at a block or lines style comment?
763 (setq leader "// ")) 770 (if (and (looking-at (concat "\\(" c-comment-start-regexp
764 (goto-char here) 771 "\\)[ \t]+"))
765 (delete-region (progn (skip-chars-backward " \t") (point)) 772 (string-equal (match-string 1) "//"))
766 (progn (skip-chars-forward " \t") (point))) 773 ;; line style
767 (newline) 774 (setq leader "// "))
768 ;; to avoid having an anchored comment that c-indent-line will 775 (goto-char here)
769 ;; trip up on 776 (delete-region (progn (skip-chars-backward " \t") (point))
770 (insert " " leader) 777 (progn (skip-chars-forward " \t") (point)))
771 (c-indent-line)))) 778 (newline)
779 ;; to avoid having an anchored comment that c-indent-line will
780 ;; trip up on
781 (insert " " leader)
782 (c-indent-line))))))
772 783
773;; advice for indent-new-comment-line for older Emacsen 784;; advice for indent-new-comment-line for older Emacsen
774(if (boundp 'comment-line-break-function) 785(if (boundp 'comment-line-break-function)