[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Automatic smart indentation
From: |
Martin Stone Davis |
Subject: |
Automatic smart indentation |
Date: |
Thu, 30 Oct 2003 15:38:42 -0800 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5) Gecko/20031007 |
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.
- Automatic smart indentation,
Martin Stone Davis <=