🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.bug
Article #1783

indent-sexp looping [18.55]

#1783
From: Steve Greenbaum
Date: Thu, 21 Dec 1989 23:08
46 lines
1991 bytes
Hi,

Here is a bug in Emacs 18.55.  I'm using it on an HP 9000/370 with HPUX 6.2
and X11.

Function indent-sexp, when trying to indent things like the following
expression fragment, will sometimes get into an infinite loop:

      ( ;)

To get the looping behavior there must not be an "extra" right paren later in
the file.  For example, the following will NOT loop:

      ( ;)
      )

The problem is that forward-sexp thinks the first example is a complete expr,
but parse-partial-sexp does not.  Forward-sexp is used by indent-sexp to check
that there is a complete expression.  The first example passes this test, then
the rest of indent-sexp, using parse-partial-sexp, loops looking for
parenthesis nesting level 0, which it correctly does not find (i.e. variabe
next-depth remains greater than zero).  The second example works because the
added paren closes the expression, even though forward-sexp incorrectly thinks
the commented-out paren is the closing paren.

Of course this can happen with realalistic examples too (that's how I found
it).

A simple fix is to add a "last-point" variable to indent-sexp, initialized to
-1, and add:

	(or outer-loop-done
	    (setq outer-loop-done (= (point) last-point))
	    (setq last-point (point))
	)

to the end of the outer while loop.  A better but more complicated fix would
be to make forward-sexp smart about comments.


  Steve Greenbaum
  HP Labs
  1501 Page Mill Road
  Palo Alto, CA  94304
  (415) 857-5181
  greenbaum@hplabs.hp.com
Technical Details
Message-ID: <8912212308.AA11906@hplsg.HPL.HP.COM>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!samsung!zaphod.mps.ohio-state.edu!tut.cis.ohio-state.edu!HPLABS.HP.COM!steve%hplsg

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!samsung!zaphod.mps.ohio-state.edu!tut.cis.ohio-state.edu!HPLABS.HP.COM!steve%hplsg
From: steve%hplsg@HPLABS.HP.COM (Steve Greenbaum)
Newsgroups: gnu.emacs.bug
Subject: indent-sexp looping [18.55]
Message-ID: <8912212308.AA11906@hplsg.HPL.HP.COM>
Date: 21 Dec 89 23:08:38 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 46