changeset 75798:8496bd7b062a

(indent-sexp): Clean up termination condition -- don't fail to stop at endpos.
author Richard M. Stallman <rms@gnu.org>
date Sun, 11 Feb 2007 11:11:54 +0000
parents 1c398694f7b2
children 18c1aeb90b42
files lisp/emacs-lisp/lisp-mode.el
diffstat 1 files changed, 12 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/emacs-lisp/lisp-mode.el	Sun Feb 11 11:11:09 2007 +0000
+++ b/lisp/emacs-lisp/lisp-mode.el	Sun Feb 11 11:11:54 2007 +0000
@@ -1130,19 +1130,25 @@
 					 (make-list (- next-depth) nil))
 		     last-depth (- last-depth next-depth)
 		     next-depth 0)))
-	(or outer-loop-done endpos
-	    (setq outer-loop-done (<= next-depth 0)))
-	(if outer-loop-done
-	    (forward-line 1)
+	(forward-line 1)
+	;; Decide whether to exit.
+	(if endpos
+	    ;; If we have already reached the specified end,
+	    ;; give up and do not reindent this line.
+	    (if (<= endpos (point))
+		(setq outer-loop-done t))
+	  ;; If no specified end, we are done if we have finished one sexp.
+	  (if (<= next-depth 0)
+	      (setq outer-loop-done t)))
+	(unless outer-loop-done
 	  (while (> last-depth next-depth)
 	    (setq indent-stack (cdr indent-stack)
 		  last-depth (1- last-depth)))
 	  (while (< last-depth next-depth)
 	    (setq indent-stack (cons nil indent-stack)
 		  last-depth (1+ last-depth)))
-	  ;; Now go to the next line and indent it according
+	  ;; Now indent the next line according
 	  ;; to what we learned from parsing the previous one.
-	  (forward-line 1)
 	  (setq bol (point))
 	  (skip-chars-forward " \t")
 	  ;; But not if the line is blank, or just a comment