Article View: gnu.emacs.help
Article #189451Re: indentation in text-mode
From: Ray Nickson
Date: Tue, 05 Feb 1991 14:11
Date: Tue, 05 Feb 1991 14:11
93 lines
4208 bytes
4208 bytes
In article <9102040850.AA16477@telotech.UUCP> of gnu.emacs.sources,
telotech!bsa@USENET.INS.CWRU.EDU writes:
This is my "simple indent" package. I wrote this to allow me to edit files
which don't have major modes and/or for which major modes would be
prohibitively difficult to write.
[I didn't follow up in .sources because that would be The Wrong Thing].
I've been working on a `genind' (general indent) package intended for
such cases. The idea is that you supply a configuration file tailored
to your particular indentation preferences. Here's my `gel' file for
my (rather nonstandard) preferred Prolog indentation style:
----start prolog.gel----
;; -*-emacs-lisp-*-
(require 'genind)
(setq genind-previous-list
'( ("\\.$" . 0)
("^[:?]-" . 3)
("($" . (+ 4))
((& ":-$" ?\)) . (match redo 4))
((& "->$" ?\)) . (match redo 4))
(":-$" . (+ 4))
("->$" . (+ 4))
(?\( . (open 1))
(?\) . (match redo 0))
(?\[ . (open 1))
(?\] . (match redo 0))
(",$" . (+ 0))
("|$" . (open 4))
("^;" . (+ 4))
))
(setq genind-current-list
'( ("^;" . (open 0))
("^)" . (open 0))
))
(setq genind-indent-triggers
'( ?\( ?\) ?; ))
(genind-bindings)
----end prolog.gel----
Genind is only in the early prototype stage (only 200 lines of elisp
at present), and may never get beyond it. In fact, it doesn't
currently handle anything other than what I use above.
Here's some docs:
(documentation 'genind-indent-line)
"Indent the current line based on the variables
genind-previous-list and genind-current-list."
(get 'genind-previous-list 'variable-documentation)
"*List of (PATTERN . VALUE) pairs specifying indentation of a line based on
its predecessor. See genind-calculate-indent (q.v.)."
(get 'genind-current-list 'variable-documentation)
"*List of (PATTERN . VALUE) pairs specifying indentation of a line based on
its own text. See genind-calculate-indent (q.v.)."
(documentation 'genind-calculate-indent)
"Return the indentation of the current line derived by comparing LINE
against ALIST. ALIST is a list of (PATTERN . VALUE) pairs; the indentation
depends on the VALUE corresponding to the first-matched PATTERN.
pattern matching function
------- -----------------
string treat string as regexp
character with paren syntax look for unmatched paren (l or r)
atom call named function with line as arg
(! pattern) pattern does not match
(& pattern1 pattern2 ...) all patterns match
(| pattern1 pattern2 ...) any pattern matches
value indentation
----- -----------
n n
(+ n) indentation of previous line + n
(open n) indentation of innermost enclosing open paren + n
(match n) indentation of lparen matching last rparen + n
(start n) indentation of line containing lparen matching last rparen + n
(match redo n) means prepend the line with a matching lparen to this one
and recalculate, then add n"
Please send me mail if you're interested in seeing genind, or if you
have suggestions for enhancements or alternatives (I've seen gin-mode,
but feel free to remind me about it if you think it subsumes this).
Technical Details
Message-ID:
<NICKSON.91Feb5091139@circa.comp.vuw.ac.nz>Path:
arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!comp.vuw.ac.nz!nicksonReferences:
<9102040850.AA16477@telotech.UUCP>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103b8b,e66f06d6d7f9bfcb,start X-Google-Attributes: gid103b8b,public X-Google-ArrivalTime: 1991-02-04 14:49:40 PST Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!comp.vuw.ac.nz!nickson From: Ray.Nickson@comp.vuw.ac.nz (Ray Nickson) Newsgroups: gnu.emacs.help Subject: Re: indentation in text-mode Message-ID: <NICKSON.91Feb5091139@circa.comp.vuw.ac.nz> Date: 5 Feb 91 14:11:39 GMT References: <9102040850.AA16477@telotech.UUCP> Sender: news@comp.vuw.ac.nz (News Admin) Distribution: gnu Organization: Victoria University of Wellington, Wellington, New Zealand Lines: 93 Nntp-Posting-Host: circa.comp.vuw.ac.nz In-Reply-To: telotech!bsa@USENET.INS.CWRU.EDU's message of 4 Feb 91 13:50:10 GMT