comparison lisp/emacs-lisp/lisp-mode.el @ 10594:aadef46f00f7

(lisp-indent-region): Set endmark before indenting first line. (indent-sexp): Fixes for ENDPOS != nil case--use nil as starting-point, and don't insist on a complete sexp.
author Richard M. Stallman <rms@gnu.org>
date Mon, 30 Jan 1995 02:16:26 +0000
parents 738999b0296f
children 04591bafb562
comparison
equal deleted inserted replaced
10593:7ae93c2ee7a2 10594:aadef46f00f7
521 If optional arg ENDPOS is given, indent each line, stopping when 521 If optional arg ENDPOS is given, indent each line, stopping when
522 ENDPOS is encountered." 522 ENDPOS is encountered."
523 (interactive) 523 (interactive)
524 (let ((indent-stack (list nil)) 524 (let ((indent-stack (list nil))
525 (next-depth 0) 525 (next-depth 0)
526 (starting-point (point)) 526 ;; If ENDPOS is non-nil, use nil as STARTING-POINT
527 ;; so that calculate-lisp-indent will find the beginning of
528 ;; the defun we are in.
529 ;; If ENDPOS is nil, it is safe not to scan before point
530 ;; since every line we indent is more deeply nested than point is.
531 (starting-point (if endpos nil (point)))
527 (last-point (point)) 532 (last-point (point))
528 last-depth bol outer-loop-done inner-loop-done state this-indent) 533 last-depth bol outer-loop-done inner-loop-done state this-indent)
529 ;; Get error now if we don't have a complete sexp after point. 534 (or endpos
530 (save-excursion (forward-sexp 1)) 535 ;; Get error now if we don't have a complete sexp after point.
536 (save-excursion (forward-sexp 1)))
531 (save-excursion 537 (save-excursion
532 (setq outer-loop-done nil) 538 (setq outer-loop-done nil)
533 (while (if endpos (< (point) endpos) 539 (while (if endpos (< (point) endpos)
534 (not outer-loop-done)) 540 (not outer-loop-done))
535 (setq last-depth next-depth 541 (setq last-depth next-depth
566 (progn 572 (progn
567 (setq indent-stack (append indent-stack 573 (setq indent-stack (append indent-stack
568 (make-list (- next-depth) nil)) 574 (make-list (- next-depth) nil))
569 last-depth (- last-depth next-depth) 575 last-depth (- last-depth next-depth)
570 next-depth 0))) 576 next-depth 0)))
571 (or outer-loop-done 577 (or outer-loop-done endpos
572 (setq outer-loop-done (<= next-depth 0))) 578 (setq outer-loop-done (<= next-depth 0)))
573 (if outer-loop-done 579 (if outer-loop-done
574 (forward-line 1) 580 (forward-line 1)
575 (while (> last-depth next-depth) 581 (while (> last-depth next-depth)
576 (setq indent-stack (cdr indent-stack) 582 (setq indent-stack (cdr indent-stack)
606 (setq last-point (point))))))) 612 (setq last-point (point)))))))
607 613
608 ;; Indent every line whose first char is between START and END inclusive. 614 ;; Indent every line whose first char is between START and END inclusive.
609 (defun lisp-indent-region (start end) 615 (defun lisp-indent-region (start end)
610 (save-excursion 616 (save-excursion
611 (goto-char start)
612 (and (bolp) (not (eolp))
613 (lisp-indent-line))
614 (let ((endmark (copy-marker end))) 617 (let ((endmark (copy-marker end)))
618 (goto-char start)
619 (and (bolp) (not (eolp))
620 (lisp-indent-line))
615 (indent-sexp endmark) 621 (indent-sexp endmark)
616 (set-marker endmark nil)))) 622 (set-marker endmark nil))))
617 623
618 ;;;; Lisp paragraph filling commands. 624 ;;;; Lisp paragraph filling commands.
619 625