aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1993-11-11 03:02:18 +0000
committerRichard M. Stallman1993-11-11 03:02:18 +0000
commit4fd99ee43a45916ff071c7e7a7d84a28193ffd5b (patch)
tree22adeb9d2f26273ec5b90f18e0899b4cb0f4ac37
parent4baf56205b483c0d19da33251fb1772373375227 (diff)
downloademacs-4fd99ee43a45916ff071c7e7a7d84a28193ffd5b.tar.gz
emacs-4fd99ee43a45916ff071c7e7a7d84a28193ffd5b.zip
(c-indent-region): When looking for a sexp that ends
past this line, make sure it really starts on this line.
-rw-r--r--lisp/progmodes/c-mode.el12
1 files changed, 9 insertions, 3 deletions
diff --git a/lisp/progmodes/c-mode.el b/lisp/progmodes/c-mode.el
index fa3e656fb24..1bc95a77243 100644
--- a/lisp/progmodes/c-mode.el
+++ b/lisp/progmodes/c-mode.el
@@ -1189,7 +1189,7 @@ If within a string or comment, move by sentences instead of statements."
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
@@ -1203,10 +1203,16 @@ If within a string or comment, move by sentences instead of statements."
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)))