🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.bug
Article #87671

[19.25] lisp-indent-region indents improperly if region has >1 sexp

#87671
From: Mike Long
Date: Thu, 08 Sep 1994 17:40
47 lines
2021 bytes
In GNU Emacs 19.25.2 of Thu Aug 11 1994 on cthulhu (sparc-sun-sunos4.1.3)

lisp-indent-region doesn't DTRT if there is more than one sexp in the
region.  Only the first sexp is indented.  For example, if the region
in a lisp-mode buffer contains:

(sexp-1 arg1
arg2)
  (sexp-2) ; test
  (sexp-3)

and indent-region is called, then the result is:

(sexp-1 arg1
	arg2)
  (sexp-2)				; test
  (sexp-3)

instead of what it should be:

(sexp-1 arg1
	arg2)
(sexp-2)				; test
(sexp-3)

Work-around:
(add-hook 'lisp-mode-hook (lambda () (setq indent-region-function nil)))

The following fix seems to work, but may not be the best solution:

(defun lisp-indent-region (start end)
  (save-excursion
    (goto-char start)
    (let ((endmark (copy-marker end)))
      (while (< (point) endmark)
	(and (bolp) (not (eolp))
	     (lisp-indent-line))
	(indent-sexp endmark)
	(forward-sexp 1)
	(forward-line 1))
      (set-marker endmark nil))))

-- 
Mike Long                                         Mike.Long@Analog.com
VLSI Design Engineer                    (PGP 2.6 public key available)
Analog Devices, CPD Division
Norwood, MA 02062 USA                assert(*this!=opinionof(Analog));
Technical Details
Message-ID: <9409081736.AA12934@cthulhu>
Path: arc1-ca.pugleaf.net!nntp.gmd.de!xlink.net!slsv6bt!slbh01.bln.sel.alcatel.de!rcvie!Austria.EU.net!EU.net!howland.reston.ans.net!math.ohio-state.edu!pacific.mps.ohio-state.edu!cis.ohio-state.edu!analog.COM!mike.long

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fb2f1,1ec5b48e4b1c32b2,start
X-Google-Attributes: gidfb2f1,public
X-Google-ArrivalTime: 1994-09-09 01:17:01 PST
Path: arc1-ca.pugleaf.net!nntp.gmd.de!xlink.net!slsv6bt!slbh01.bln.sel.alcatel.de!rcvie!Austria.EU.net!EU.net!howland.reston.ans.net!math.ohio-state.edu!pacific.mps.ohio-state.edu!cis.ohio-state.edu!analog.COM!mike.long
From: mike.long@analog.COM (Mike Long)
Newsgroups: gnu.emacs.bug
Subject: [19.25] lisp-indent-region indents improperly if region has >1 sexp
Date: 8 Sep 1994 13:40:10 -0400
Organization: Analog Devices Inc, Norwood MA, USA
Lines: 47
Sender: daemon@cis.ohio-state.edu
Approved: bug-gnu-emacs@prep.ai.mit.edu
Distribution: gnu
Message-ID: <9409081736.AA12934@cthulhu>
Reply-To: Mike Long <Mike.Long@analog.com>