comparison lisp/cc-mode/cc-cmds.el @ 203:850242ba4a81 r20-3b28

Import from CVS: tag r20-3b28
author cvs
date Mon, 13 Aug 2007 10:02:21 +0200
parents 489f57a838ef
children
comparison
equal deleted inserted replaced
202:61eefc8fc970 203:850242ba4a81
5 ;; Authors: 1992-1997 Barry A. Warsaw 5 ;; Authors: 1992-1997 Barry A. Warsaw
6 ;; 1987 Dave Detlefs and Stewart Clamen 6 ;; 1987 Dave Detlefs and Stewart Clamen
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.18 10 ;; Version: See cc-mode.el
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.
14 14
15 ;; GNU Emacs is free software; you can redistribute it and/or modify 15 ;; GNU Emacs is free software; you can redistribute it and/or modify
755 755
756 756
757 ;; for proposed new variable comment-line-break-function 757 ;; for proposed new variable comment-line-break-function
758 (defun c-comment-line-break-function (&optional soft) 758 (defun c-comment-line-break-function (&optional soft)
759 ;; we currently don't do anything with soft line breaks 759 ;; we currently don't do anything with soft line breaks
760 (let ((literal (c-in-literal))) 760 (let ((literal (c-in-literal))
761 at-comment-col)
761 (cond 762 (cond
762 ((eq literal 'string)) 763 ((eq literal 'string))
763 ((or (not c-comment-continuation-stars) 764 ((or (not c-comment-continuation-stars)
764 (not literal)) 765 (not literal))
765 (indent-new-comment-line soft)) 766 (indent-new-comment-line soft))
766 (t (let ((here (point)) 767 (t (let ((here (point))
767 (leader c-comment-continuation-stars)) 768 (leader c-comment-continuation-stars))
768 (back-to-indentation) 769 (back-to-indentation)
770 ;; comment could be hanging
771 (if (not (c-in-literal))
772 (progn
773 (forward-line 1)
774 (forward-comment -1)
775 (setq at-comment-col (= (current-column) comment-column))))
769 ;; are we looking at a block or lines style comment? 776 ;; are we looking at a block or lines style comment?
770 (if (and (looking-at (concat "\\(" c-comment-start-regexp 777 (if (and (looking-at (concat "\\(" c-comment-start-regexp
771 "\\)[ \t]+")) 778 "\\)[ \t]+"))
772 (string-equal (match-string 1) "//")) 779 (string-equal (match-string 1) "//"))
773 ;; line style 780 ;; line style
777 (progn (skip-chars-forward " \t") (point))) 784 (progn (skip-chars-forward " \t") (point)))
778 (newline) 785 (newline)
779 ;; to avoid having an anchored comment that c-indent-line will 786 ;; to avoid having an anchored comment that c-indent-line will
780 ;; trip up on 787 ;; trip up on
781 (insert " " leader) 788 (insert " " leader)
789 (if at-comment-col
790 (indent-for-comment))
782 (c-indent-line)))))) 791 (c-indent-line))))))
783 792
784 ;; advice for indent-new-comment-line for older Emacsen 793 ;; advice for indent-new-comment-line for older Emacsen
785 (if (boundp 'comment-line-break-function) 794 (if (boundp 'comment-line-break-function)
786 nil 795 nil
1131 1140
1132 ;; for progress reporting 1141 ;; for progress reporting
1133 (defvar c-progress-info nil) 1142 (defvar c-progress-info nil)
1134 1143
1135 (defun c-progress-init (start end context) 1144 (defun c-progress-init (start end context)
1136 ;; start the progress update messages. if this emacs doesn't have a 1145 (cond
1137 ;; built-in timer, just be dumb about it 1146 ;; Be silent
1138 (if (not (fboundp 'current-time)) 1147 ((not c-progress-interval))
1139 (message "indenting region... (this may take a while)") 1148 ;; Start the progress update messages. If this Emacs doesn't have
1140 ;; if progress has already been initialized, do nothing. otherwise 1149 ;; a built-in timer, just be dumb about it.
1141 ;; initialize the counter with a vector of: 1150 ((not (fboundp 'current-time))
1142 ;; [start end lastsec context] 1151 (message "indenting region... (this may take a while)"))
1143 (if c-progress-info 1152 ;; If progress has already been initialized, do nothing. otherwise
1144 () 1153 ;; initialize the counter with a vector of:
1145 (setq c-progress-info (vector start 1154 ;; [start end lastsec context]
1155 (c-progress-info)
1156 (t (setq c-progress-info (vector start
1146 (save-excursion 1157 (save-excursion
1147 (goto-char end) 1158 (goto-char end)
1148 (point-marker)) 1159 (point-marker))
1149 (nth 1 (current-time)) 1160 (nth 1 (current-time))
1150 context)) 1161 context))
1151 (message "indenting region...")))) 1162 (message "indenting region..."))
1163 ))
1152 1164
1153 (defun c-progress-update () 1165 (defun c-progress-update ()
1154 ;; update progress 1166 ;; update progress
1155 (if (not (and c-progress-info c-progress-interval)) 1167 (if (not (and c-progress-info c-progress-interval))
1156 nil 1168 nil
1167 (aset c-progress-info 2 now))) 1179 (aset c-progress-info 2 now)))
1168 ))) 1180 )))
1169 1181
1170 (defun c-progress-fini (context) 1182 (defun c-progress-fini (context)
1171 ;; finished 1183 ;; finished
1172 (if (or (eq context (aref c-progress-info 3)) 1184 (if (not c-progress-interval)
1173 (eq context t)) 1185 nil
1174 (progn 1186 (if (or (eq context (aref c-progress-info 3))
1175 (set-marker (aref c-progress-info 1) nil) 1187 (eq context t))
1176 (setq c-progress-info nil) 1188 (progn
1177 (message "indenting region...done")))) 1189 (set-marker (aref c-progress-info 1) nil)
1190 (setq c-progress-info nil)
1191 (message "indenting region...done")))))
1178 1192
1179 1193
1180 1194
1181 ;;; This page handles insertion and removal of backslashes for C macros. 1195 ;;; This page handles insertion and removal of backslashes for C macros.
1182 1196