unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Martin Stone Davis <m0davis@pacbell.net>
Subject: Automatic smart indentation
Date: Thu, 30 Oct 2003 15:38:42 -0800	[thread overview]
Message-ID: <bns7fk$r3q$1@sea.gmane.org> (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.

             reply	other threads:[~2003-10-30 23:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-30 23:38 Martin Stone Davis [this message]
     [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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='bns7fk$r3q$1@sea.gmane.org' \
    --to=m0davis@pacbell.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).