comparison lisp/progmodes/c-mode.el @ 4976:a81642d50a8e

(c-indent-region): When looking for a sexp that ends past this line, make sure it really starts on this line.
author Richard M. Stallman <rms@gnu.org>
date Thu, 11 Nov 1993 03:02:18 +0000
parents e7348af6762b
children e3c47db646fd
comparison
equal deleted inserted replaced
4975:db0c6ed6f145 4976:a81642d50a8e
1187 (let ((endmark (copy-marker end)) 1187 (let ((endmark (copy-marker end))
1188 (c-tab-always-indent t)) 1188 (c-tab-always-indent t))
1189 (while (and (bolp) (not (eolp))) 1189 (while (and (bolp) (not (eolp)))
1190 ;; Indent one line as with TAB. 1190 ;; Indent one line as with TAB.
1191 (let ((shift-amt (c-indent-line)) 1191 (let ((shift-amt (c-indent-line))
1192 nextline sexpend) 1192 nextline sexpbeg sexpend)
1193 (save-excursion 1193 (save-excursion
1194 ;; Find beginning of following line. 1194 ;; Find beginning of following line.
1195 (save-excursion 1195 (save-excursion
1196 (forward-line 1) (setq nextline (point))) 1196 (forward-line 1) (setq nextline (point)))
1197 ;; Find first beginning-of-sexp for sexp extending past this line. 1197 ;; Find first beginning-of-sexp for sexp extending past this line.
1201 (progn 1201 (progn
1202 (forward-sexp 1) 1202 (forward-sexp 1)
1203 (setq sexpend (point-marker))) 1203 (setq sexpend (point-marker)))
1204 (error (setq sexpend nil) 1204 (error (setq sexpend nil)
1205 (goto-char nextline))) 1205 (goto-char nextline)))
1206 (skip-chars-forward " \t\n"))) 1206 (skip-chars-forward " \t\n"))
1207 ;; Make sure the sexp we found really starts on the
1208 ;; current line and extends past it.
1209 (goto-char sexpend)
1210 (backward-sexp 1)
1211 (setq sexpbeg (point)))
1207 ;; If that sexp ends within the region, 1212 ;; If that sexp ends within the region,
1208 ;; indent it all at once, fast. 1213 ;; indent it all at once, fast.
1209 (if (and sexpend (> sexpend nextline) (<= sexpend endmark)) 1214 (if (and sexpend (> sexpend nextline) (<= sexpend endmark)
1215 (< sexpbeg nextline))
1210 (progn 1216 (progn
1211 (indent-c-exp) 1217 (indent-c-exp)
1212 (goto-char sexpend))) 1218 (goto-char sexpend)))
1213 ;; Move to following line and try again. 1219 ;; Move to following line and try again.
1214 (and sexpend (set-marker sexpend nil)) 1220 (and sexpend (set-marker sexpend nil))