* How to write a major mode?
@ 2003-08-21 17:50 Arjan Bos
2003-08-21 18:23 ` Phillip Lord
` (3 more replies)
0 siblings, 4 replies; 10+ messages in thread
From: Arjan Bos @ 2003-08-21 17:50 UTC (permalink / raw)
Hi all,
Are there any pointers to documentation that show me how to program my
own major mode? We created our own language with antlr, and of course we
want it font-locked and indented automatically from within emacs.
1) Which functions do I need to create?
2) Are there any elisp docs out there that could help me with those
function?
3) What is the best way to provide indenting and font-locking?
Is there a small, well documented major-mode that I can use as a basis?
These are a lot of questions. I hope I get answers to them all ;-)
TIA
Arjan Bos
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: How to write a major mode?
2003-08-21 17:50 How to write a major mode? Arjan Bos
@ 2003-08-21 18:23 ` Phillip Lord
2003-08-27 20:16 ` Kai Großjohann
2003-08-21 18:24 ` Lute Kamstra
` (2 subsequent siblings)
3 siblings, 1 reply; 10+ messages in thread
From: Phillip Lord @ 2003-08-21 18:23 UTC (permalink / raw)
>>>>> "Arjan" == Arjan Bos <Arjan.Bos@icu.nl> writes:
Arjan> Hi all,
Arjan> Are there any pointers to documentation that show me how to
Arjan> program my own major mode? We created our own language with
Arjan> antlr, and of course we want it font-locked and indented
Arjan> automatically from within emacs.
Arjan> 1) Which functions do I need to create?
Arjan> 2) Are there any elisp docs out there that could help me with
Arjan> those
Arjan> function?
Arjan> 3) What is the best way to provide indenting and
Arjan> font-locking?
Arjan> Is there a small, well documented major-mode that I can use
Arjan> as a basis?
Arjan> These are a lot of questions. I hope I get answers to them
Arjan> all ;-)
There is a emacs lisp primer, and manual, which you can get from the
GNU sites. They are both fairly good. There is also, of course, of lot
of source, much of which is well documented which you can read.
In your case I think you want to take a look at "generic.el" and
"generic-x.el" which are designed for building small major modes, with
font locking, and indentation.
Phil
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: How to write a major mode?
2003-08-21 17:50 How to write a major mode? Arjan Bos
2003-08-21 18:23 ` Phillip Lord
@ 2003-08-21 18:24 ` Lute Kamstra
2003-08-21 20:54 ` Johan Bockgård
2003-08-21 23:53 ` Alex Schroeder
2003-08-26 18:40 ` Arjan Bos
2003-08-27 20:18 ` Kai Großjohann
3 siblings, 2 replies; 10+ messages in thread
From: Lute Kamstra @ 2003-08-21 18:24 UTC (permalink / raw)
Arjan Bos <Arjan.Bos@icu.nl> writes:
> Are there any pointers to documentation that show me how to program
> my own major mode? We created our own language with antlr, and of
> course we want it font-locked and indented automatically from within
> emacs.
>
> 1) Which functions do I need to create?
> 2) Are there any elisp docs out there that could help me with those
> function?
> 3) What is the best way to provide indenting and font-locking?
The Emacs Lisp Reference Manual has a chapter about writing major
modes. If I recall correctly, http://www.emacswiki.org has some
useful information as well.
> Is there a small, well documented major-mode that I can use as a
> basis?
Take a look at some of the major modes that come with Emacs. An
example of a small mode is text-mode (lisp/textmodes/text-mode.el).
Lute.
--
(spook) => "militia benelux New World Order"
(insert-file-contents "~/.signature") => (error "`~/.signature' too rude")
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: How to write a major mode?
2003-08-21 18:24 ` Lute Kamstra
@ 2003-08-21 20:54 ` Johan Bockgård
2003-08-21 23:53 ` Alex Schroeder
1 sibling, 0 replies; 10+ messages in thread
From: Johan Bockgård @ 2003-08-21 20:54 UTC (permalink / raw)
Lute Kamstra <Lute.Kamstra@cwi.nl> writes:
> Arjan Bos <Arjan.Bos@icu.nl> writes:
> If I recall correctly, http://www.emacswiki.org has some useful
> information as well.
http://www.emacswiki.org/cgi-bin/wiki.pl/ModeTutorial
>> Is there a small, well documented major-mode that I can use as a
>> basis?
http://www.emacswiki.org/cgi-bin/wiki.pl/SampleMode
--
Johan Bockgård
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: How to write a major mode?
2003-08-21 18:24 ` Lute Kamstra
2003-08-21 20:54 ` Johan Bockgård
@ 2003-08-21 23:53 ` Alex Schroeder
1 sibling, 0 replies; 10+ messages in thread
From: Alex Schroeder @ 2003-08-21 23:53 UTC (permalink / raw)
Lute Kamstra <Lute.Kamstra@cwi.nl> writes:
> If I recall correctly, http://www.emacswiki.org has some useful
> information as well.
Indeed. Here is from
http://www.emacswiki.org/cgi-bin/wiki.pl/CategoryCode
How to start writing a new major mode:
* GenericMode -- for very simple modes including font-locking and comments
* DerivedMode -- for new modes very similar to existing modes
* SampleMode -- complete elisp example for a real major mode
* ModeTutorial -- a tutorial for mode writers
Alex.
--
http://www.emacswiki.org/alex/
There is no substitute for experience.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: How to write a major mode?
2003-08-21 17:50 How to write a major mode? Arjan Bos
2003-08-21 18:23 ` Phillip Lord
2003-08-21 18:24 ` Lute Kamstra
@ 2003-08-26 18:40 ` Arjan Bos
2003-08-28 13:49 ` Rob Thorpe
2003-08-27 20:18 ` Kai Großjohann
3 siblings, 1 reply; 10+ messages in thread
From: Arjan Bos @ 2003-08-26 18:40 UTC (permalink / raw)
Many thanks to all that replied! Emacs wiki, the sample mode and the
mode tutorial proved very usedful indeed. Next to that, a colleague of
mine turned up with an O'Reilly book on customizing emacs. It deals with
gnu-emacs 19.18, but I quess that the principles haven't changed that much.
Again, thanks for all the fantastic info
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: How to write a major mode?
2003-08-21 18:23 ` Phillip Lord
@ 2003-08-27 20:16 ` Kai Großjohann
2003-08-28 10:59 ` Phillip Lord
0 siblings, 1 reply; 10+ messages in thread
From: Kai Großjohann @ 2003-08-27 20:16 UTC (permalink / raw)
Phillip Lord <p.lord@russet.org.uk> writes:
> In your case I think you want to take a look at "generic.el" and
> "generic-x.el" which are designed for building small major modes, with
> font locking, and indentation.
Does generic.el do indentation?
--
Two cafe au lait please, but without milk.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: How to write a major mode?
2003-08-21 17:50 How to write a major mode? Arjan Bos
` (2 preceding siblings ...)
2003-08-26 18:40 ` Arjan Bos
@ 2003-08-27 20:18 ` Kai Großjohann
3 siblings, 0 replies; 10+ messages in thread
From: Kai Großjohann @ 2003-08-27 20:18 UTC (permalink / raw)
In addition to the suggestions from the others, see the node
"(elisp)Major Modes" in Info.
You will have to download and install the Emacs Lisp Reference
manual, available from ftp.gnu.org and its mirrors.
Then, C-h i and then g and then enter the above node name, terminated
with RET.
--
Two cafe au lait please, but without milk.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: How to write a major mode?
2003-08-27 20:16 ` Kai Großjohann
@ 2003-08-28 10:59 ` Phillip Lord
0 siblings, 0 replies; 10+ messages in thread
From: Phillip Lord @ 2003-08-28 10:59 UTC (permalink / raw)
>>>>> "Kai" == Kai Großjohann <kai.grossjohann@gmx.net> writes:
Kai> Phillip Lord <p.lord@russet.org.uk> writes:
>> In your case I think you want to take a look at "generic.el" and
>> "generic-x.el" which are designed for building small major modes,
>> with font locking, and indentation.
Kai> Does generic.el do indentation?
No it doesn't. My mistake.
indent.el does do indentation however, and there are a couple of
functions in there which will be good for many new modes.
Phil
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: How to write a major mode?
2003-08-26 18:40 ` Arjan Bos
@ 2003-08-28 13:49 ` Rob Thorpe
0 siblings, 0 replies; 10+ messages in thread
From: Rob Thorpe @ 2003-08-28 13:49 UTC (permalink / raw)
Arjan Bos <Arjan.Bos@icu.nl> wrote in message news:<3f4ba9a4$0$45387$1b62eedf@news.wanadoo.nl>...
> Many thanks to all that replied! Emacs wiki, the sample mode and the
> mode tutorial proved very usedful indeed. Next to that, a colleague of
> mine turned up with an O'Reilly book on customizing emacs. It deals with
> gnu-emacs 19.18, but I quess that the principles haven't changed that much.
>
> Again, thanks for all the fantastic info
In addition, I wrote a short mode in answer to a question
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&threadm=1a61f7e5.0206240840.321cc8bb%40posting.google.com&rnum=21&prev=/groups%3Fq%3D%2522robert%2Bthorpe%2522%2Bgroup:comp.emacs%26hl%3Den%26lr%3D%26ie%3DUTF-8%26start%3D20%26sa%3DN
also, awk mode-and asm-mode are simple and easy to read examples of
modes.
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2003-08-28 13:49 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-08-21 17:50 How to write a major mode? Arjan Bos
2003-08-21 18:23 ` Phillip Lord
2003-08-27 20:16 ` Kai Großjohann
2003-08-28 10:59 ` Phillip Lord
2003-08-21 18:24 ` Lute Kamstra
2003-08-21 20:54 ` Johan Bockgård
2003-08-21 23:53 ` Alex Schroeder
2003-08-26 18:40 ` Arjan Bos
2003-08-28 13:49 ` Rob Thorpe
2003-08-27 20:18 ` Kai Großjohann
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).