From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: use.address@my.homepage.invalid (Chris Gordon-Smith) Newsgroups: gmane.emacs.help Subject: Re: Tabs and Spaces Date: 27 May 2009 20:38:25 GMT Organization: SimSoup Message-ID: <785mm1F1km44lU1@mid.individual.net> References: <77vbbiF1jhhubU1@mid.individual.net> <780hs5F1jleh1U1@mid.individual.net> <87r5ycu0w6.fsf@galatea.local> <7835dsF1kbm4vU1@mid.individual.net> <8763fn5vz0.fsf@galatea.local> NNTP-Posting-Host: lo.gmane.org X-Trace: ger.gmane.org 1243456843 25442 80.91.229.12 (27 May 2009 20:40:43 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 27 May 2009 20:40:43 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed May 27 22:40:41 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1M9PvR-0001yt-46 for geh-help-gnu-emacs@m.gmane.org; Wed, 27 May 2009 22:40:37 +0200 Original-Received: from localhost ([127.0.0.1]:50963 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M9PvQ-0004AW-Ky for geh-help-gnu-emacs@m.gmane.org; Wed, 27 May 2009 16:40:36 -0400 Original-Path: news.stanford.edu!newsfeed.stanford.edu!goblin2!goblin.stu.neva.ru!newsfeed.freenet.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 62 Original-X-Trace: individual.net JXw6IKjytj7RnKpZbOQtFQ9sA/NhHFUpeYydEFkVjZ/ExGc4n6 X-Orig-Path: not-for-mail Cancel-Lock: sha1:kbirQVzxSLesqqgy2ySJCLWsPn0= User-Agent: tin/1.9.3-20080506 ("Dalintober") (UNIX) (Linux/2.6.26-2-686 (i686)) Original-Xref: news.stanford.edu gnu.emacs.help:169552 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:64784 Archived-At: Pascal J. Bourguignon wrote: > "Drew Adams" writes: > >>> Since it is unlikely that the built in emacs parsing / >>> indentation will be able to handle my modified syntax,... >>> For the longer term, I definitely want to work out how >>> to customise the indentation for my purposes. >> >> It's not hard, actually. It's just not well documented (IMO). >> >> See the Emacs manual, node `Lisp Indent'. >> >> Personally, I think the explanation given there is inadequate, and this (or >> more) should really be in the Elisp manual (you need some Lisp code to customize >> indentation of various Lisp sexps) - there is nothing in the Lisp manual about >> it. I've just filed a doc bug about this. >> >> After reading that node, `grep' the Lisp source code for places where it puts >> property `lisp-indent-function' on various function and macro symbols. Just copy >> what's done there. See also `C-h f lisp-indent-function', which describes the >> function that uses the symbol property. > > Well sexp indenting is the easy special case. > > I would advise rather to have a look at the pascal.el source (where > pascal-mode and pascal-indent-line are defined). This is probably > closer to what Chris would need to implement. > > However, there is one thing that could be done cf. sexps, is to > implement the forward-sexp-function hook. This is a function that > should move the cursor forward (or backward depending on its argument) > over a number of "sexp" that is, of expressions in the current > language. So given a cursor before a BEGIN, it would have to move > after the matching END, and so on for all the kinds of brackets the > languages allows (for xml, it would have to move from before to > after ). In the case of C++ however, there are a lot of > different brackets, so parsing and matching them is hard and > puzzling. (And what to do of x> (vs. x >)). > > Anyways, with this hook implemented, a lot of existing functions and > commands will start to work meaningfully in these buffers, and the > generic indenting algorithm may be usable. > Thanks to you both for this. I've had a quick look at Lisp indent and pascal.el. This will have to be a 'background' project to pick up every so often. The reality is that while I would like to get auto indentation working, my current manual approach works and there are a lot of other things I need to do. That being said, it looks like a good way to pick up Emacs Lisp on a real problem with a real benefit at the end. At the moment though I have very little understanding of Lisp; its as though it is a useful tool but I don't even know which end of it to pick up! One thought that occurred to me is that if I could get the C++ indentation to treat BEGIN and THEN in the same way as it treats "{", I might be able to make some headway. Ditto for ENDIF, END and "}". ELSE could be interesting. I define it as "} else {". Chris Gordon-Smith www.simsoup.info