diff options
author | Richard M. Stallman <rms@gnu.org> | 1995-01-30 02:16:26 +0000 |
---|---|---|
committer | Richard M. Stallman <rms@gnu.org> | 1995-01-30 02:16:26 +0000 |
commit | 33f268ecd17979857603cf93660f1f2f825954d1 (patch) | |
tree | dd5ae5785bb72c0ea406c61ecf986b39650d9714 /lisp/emacs-lisp/lisp-mode.el | |
parent | e1fd0a89b067e8d4c2bb319fec04ce498adb5d28 (diff) | |
download | emacs-33f268ecd17979857603cf93660f1f2f825954d1.tar.gz emacs-33f268ecd17979857603cf93660f1f2f825954d1.tar.bz2 emacs-33f268ecd17979857603cf93660f1f2f825954d1.zip |
(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.
Diffstat (limited to 'lisp/emacs-lisp/lisp-mode.el')
-rw-r--r-- | lisp/emacs-lisp/lisp-mode.el | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index eabe393a820..d6c299942bd 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el @@ -523,11 +523,17 @@ ENDPOS is encountered." (interactive) (let ((indent-stack (list nil)) (next-depth 0) - (starting-point (point)) + ;; If ENDPOS is non-nil, use nil as STARTING-POINT + ;; so that calculate-lisp-indent will find the beginning of + ;; the defun we are in. + ;; If ENDPOS is nil, it is safe not to scan before point + ;; since every line we indent is more deeply nested than point is. + (starting-point (if endpos nil (point))) (last-point (point)) last-depth bol outer-loop-done inner-loop-done state this-indent) - ;; Get error now if we don't have a complete sexp after point. - (save-excursion (forward-sexp 1)) + (or endpos + ;; Get error now if we don't have a complete sexp after point. + (save-excursion (forward-sexp 1))) (save-excursion (setq outer-loop-done nil) (while (if endpos (< (point) endpos) @@ -568,7 +574,7 @@ ENDPOS is encountered." (make-list (- next-depth) nil)) last-depth (- last-depth next-depth) next-depth 0))) - (or outer-loop-done + (or outer-loop-done endpos (setq outer-loop-done (<= next-depth 0))) (if outer-loop-done (forward-line 1) @@ -608,10 +614,10 @@ ENDPOS is encountered." ;; Indent every line whose first char is between START and END inclusive. (defun lisp-indent-region (start end) (save-excursion - (goto-char start) - (and (bolp) (not (eolp)) - (lisp-indent-line)) (let ((endmark (copy-marker end))) + (goto-char start) + (and (bolp) (not (eolp)) + (lisp-indent-line)) (indent-sexp endmark) (set-marker endmark nil)))) |