aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1994-01-09 21:27:07 +0000
committerRichard M. Stallman1994-01-09 21:27:07 +0000
commitd52fd67cd1d0cc4c3eb82f284000b4763acef49e (patch)
treecdbcbc7eec8d3f3cc6a2e21eeccf47470918d54f
parent94bd6573241278d58e798dd974aba8386b6ddcec (diff)
downloademacs-d52fd67cd1d0cc4c3eb82f284000b4763acef49e.tar.gz
emacs-d52fd67cd1d0cc4c3eb82f284000b4763acef49e.zip
(c-indent-region): Keep looping till reach endmark.
Treat #-lines specially.
-rw-r--r--lisp/progmodes/c-mode.el60
1 files changed, 31 insertions, 29 deletions
diff --git a/lisp/progmodes/c-mode.el b/lisp/progmodes/c-mode.el
index 246beb149be..2ffb2b82294 100644
--- a/lisp/progmodes/c-mode.el
+++ b/lisp/progmodes/c-mode.el
@@ -1220,41 +1220,43 @@ If within a string or comment, move by sentences instead of statements."
1220 (beginning-of-line) 1220 (beginning-of-line)
1221 (let ((endmark (copy-marker end)) 1221 (let ((endmark (copy-marker end))
1222 (c-tab-always-indent t)) 1222 (c-tab-always-indent t))
1223 (while (and (bolp) (not (eolp))) 1223 (while (and (bolp) (not (eobp)) (< (point) endmark))
1224 ;; Indent one line as with TAB. 1224 ;; Indent one line as with TAB.
1225 (let ((shift-amt (c-indent-line)) 1225 (let ((shift-amt (c-indent-line))
1226 nextline sexpbeg sexpend) 1226 nextline sexpbeg sexpend)
1227 (save-excursion 1227 (if (save-excursion (beginning-of-line) (looking-at "[ \t]*#"))
1228 ;; Find beginning of following line. 1228 (forward-line 1)
1229 (save-excursion 1229 (save-excursion
1230 (forward-line 1) (setq nextline (point))) 1230 ;; Find beginning of following line.
1231 ;; Find first beginning-of-sexp for sexp extending past this line. 1231 (save-excursion
1232 (beginning-of-line) 1232 (forward-line 1) (setq nextline (point)))
1233 (while (< (point) nextline) 1233 ;; Find first beginning-of-sexp for sexp extending past this line.
1234 (condition-case nil 1234 (beginning-of-line)
1235 (while (< (point) nextline)
1236 (condition-case nil
1237 (progn
1238 (forward-sexp 1)
1239 (setq sexpend (point-marker)))
1240 (error (setq sexpend nil)
1241 (goto-char nextline)))
1242 (skip-chars-forward " \t\n"))
1243 (if sexpend
1235 (progn 1244 (progn
1236 (forward-sexp 1) 1245 ;; Make sure the sexp we found really starts on the
1237 (setq sexpend (point-marker))) 1246 ;; current line and extends past it.
1238 (error (setq sexpend nil) 1247 (goto-char sexpend)
1239 (goto-char nextline))) 1248 (backward-sexp 1)
1240 (skip-chars-forward " \t\n")) 1249 (setq sexpbeg (point)))))
1241 (if sexpend 1250 ;; If that sexp ends within the region,
1251 ;; indent it all at once, fast.
1252 (if (and sexpend (> sexpend nextline) (<= sexpend endmark)
1253 (< sexpbeg nextline))
1242 (progn 1254 (progn
1243 ;; Make sure the sexp we found really starts on the 1255 (indent-c-exp)
1244 ;; current line and extends past it. 1256 (goto-char sexpend)))
1245 (goto-char sexpend) 1257 ;; Move to following line and try again.
1246 (backward-sexp 1) 1258 (and sexpend (set-marker sexpend nil))
1247 (setq sexpbeg (point))))) 1259 (forward-line 1))))
1248 ;; If that sexp ends within the region,
1249 ;; indent it all at once, fast.
1250 (if (and sexpend (> sexpend nextline) (<= sexpend endmark)
1251 (< sexpbeg nextline))
1252 (progn
1253 (indent-c-exp)
1254 (goto-char sexpend)))
1255 ;; Move to following line and try again.
1256 (and sexpend (set-marker sexpend nil))
1257 (forward-line 1)))
1258 (set-marker endmark nil)))) 1260 (set-marker endmark nil))))
1259 1261
1260(defun set-c-style (style &optional global) 1262(defun set-c-style (style &optional global)