help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Newbie major-mode and elisp question


From: Kevin Rodgers
Subject: Re: Newbie major-mode and elisp question
Date: Thu, 08 Sep 2005 11:12:03 -0600
User-agent: Mozilla Thunderbird 0.9 (X11/20041105)

sj wrote:
> I'm writing my first major mode to run Nyquist in a buffer. Nyquist is an
> extension of XLISP for audio synthesis and composition. Nyquist-mode is a
> derivative of inferior-lisp mode, its working pretty well except for one
> annoying side effect. Whenever I issue (nyquist-mode) to start a new
> Nyquist process, whatever buffer I'm currently in gets switched to
> fundamental-mode. I have isolated the problem to the
> kill-all-local-variables statement.  Is there some other way I should be
> doing this?

,----[ C-h f define-derived-mode RET ]
| define-derived-mode is a Lisp macro in `derived'.
| (define-derived-mode CHILD PARENT NAME &optional DOCSTRING &rest BODY)
|
| Create a new mode as a variant of an existing mode.
|
| The arguments to this command are as follow:
|
| CHILD:     the name of the command for the derived mode.
| PARENT:    the name of the command for the parent mode (e.g. `text-mode').
| NAME: a string which will appear in the status line (e.g. "Hypertext")
| DOCSTRING: an optional documentation string--if you do not supply one,
|            the function will attempt to invent something useful.
| BODY:      forms to execute just before running the
|            hooks for the new mode.
|
| Here is how you could define LaTeX-Thesis mode as a variant of LaTeX mode:
|
|   (define-derived-mode LaTeX-thesis-mode LaTeX-mode "LaTeX-Thesis")
|
| You could then make new key bindings for `LaTeX-thesis-mode-map'
| without changing regular LaTeX mode.  In this example, BODY is empty,
| and DOCSTRING is generated by default.
|
| On a more complicated level, the following command uses `sgml-mode' as
| the parent, and then sets the variable `case-fold-search' to nil:
|
|   (define-derived-mode article-mode sgml-mode "Article"
|     "Major mode for editing technical articles."
|     (setq case-fold-search nil))
|
| Note that if the documentation string had been left out, it would have
| been generated automatically, with a reference to the keymap.
`----

--
Kevin Rodgers





reply via email to

[Prev in Thread] Current Thread [Next in Thread]