From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Martin Stone Davis Newsgroups: gmane.emacs.help Subject: Automatic smart indentation Date: Thu, 30 Oct 2003 15:38:42 -0800 Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1067557287 28019 80.91.224.253 (30 Oct 2003 23:41:27 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 30 Oct 2003 23:41:27 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Oct 31 00:41:25 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1AFMPs-0003g6-00 for ; Fri, 31 Oct 2003 00:41:25 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1AFMPi-00006k-CW for geh-help-gnu-emacs@m.gmane.org; Thu, 30 Oct 2003 18:41:14 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.24) id 1AFMOm-0008Ul-4t for help-gnu-emacs@gnu.org; Thu, 30 Oct 2003 18:40:16 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.24) id 1AFMOD-00080V-4n for help-gnu-emacs@gnu.org; Thu, 30 Oct 2003 18:40:13 -0500 Original-Received: from [80.91.224.249] (helo=main.gmane.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1AFMO9-0007w9-CO for help-gnu-emacs@gnu.org; Thu, 30 Oct 2003 18:39:37 -0500 Original-Received: from list by main.gmane.org with local (Exim 3.35 #1 (Debian)) id 1AFMO6-00039i-00 for ; Fri, 31 Oct 2003 00:39:34 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-To: help-gnu-emacs@gnu.org Original-Received: from sea.gmane.org ([80.91.224.252]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1AFMO5-00039a-00 for ; Fri, 31 Oct 2003 00:39:33 +0100 Original-Received: from news by sea.gmane.org with local (Exim 3.35 #1 (Debian)) id 1AFMO5-0007Dy-00 for ; Fri, 31 Oct 2003 00:39:33 +0100 Original-Lines: 30 Original-X-Complaints-To: usenet@sea.gmane.org User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5) Gecko/20031007 X-Accept-Language: en-us, en X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:13673 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:13673 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.