unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Automatic smart indentation
@ 2003-10-30 23:38 Martin Stone Davis
  0 siblings, 0 replies; 3+ messages in thread
From: Martin Stone Davis @ 2003-10-30 23:38 UTC (permalink / raw)


I've read the threads in this list pertaining to indentation, but I 
haven't found a solution to the following problem:  While editing a lisp 
program, I want to keep the indentation "correct" at all times.

i.e. If I yank I want to reindent. If I delete a ), I want it to 
reindent, If I insert a (, change the name of a function from if to 
when, undo etc. etc. etc., I want to reindent.

The solution I came up with is:

(setq lisp-indent-function 'common-lisp-indent-function)
(add-hook 'after-change-functions
  	  (lambda (start end pre-change-length)
              (indent-region start (buffer-size) nil)))

The problem is that it somehow gets into an endless loop *sometimes* 
when I undo.  It might have problems in other situations, but that's 
whet I've found so far.

Any ideas?

Thanks,
-Martin

P.S. Also, I've noticed that my solution is somewhat whimsical. 
Sometimes it gets the indentation completely wrong, and lots of things 
end up on the left margin.  I'll try to come up with an reproducible 
example of this problem after I get some solution to the above.  This 
may be a problem with common-lisp-indent-function or indent-region.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-10-31 17:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.2862.1067557221.21628.help-gnu-emacs@gnu.org>
2003-10-31 16:04 ` Automatic smart indentation Kevin Rodgers
2003-10-31 17:23 ` Stefan Monnier
2003-10-30 23:38 Martin Stone Davis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).