From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kevin Rodgers Newsgroups: gmane.emacs.help Subject: Re: Newbie major-mode and elisp question Date: Thu, 08 Sep 2005 11:12:03 -0600 Message-ID: References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1126203303 2056 80.91.229.2 (8 Sep 2005 18:15:03 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 8 Sep 2005 18:15:03 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Sep 08 20:15:02 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1EDQtm-0000gt-OR for geh-help-gnu-emacs@m.gmane.org; Thu, 08 Sep 2005 20:13:23 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EDQtl-0007Ck-Lt for geh-help-gnu-emacs@m.gmane.org; Thu, 08 Sep 2005 14:13:21 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1EDQmT-00040N-5i for help-gnu-emacs@gnu.org; Thu, 08 Sep 2005 14:05:49 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1EDQmQ-0003yi-Sb for help-gnu-emacs@gnu.org; Thu, 08 Sep 2005 14:05:48 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EDQax-00010A-2H for help-gnu-emacs@gnu.org; Thu, 08 Sep 2005 13:53:55 -0400 Original-Received: from [80.91.229.2] (helo=ciao.gmane.org) by monty-python.gnu.org with esmtp (TLS-1.0:RSA_AES_128_CBC_SHA:16) (Exim 4.34) id 1EDQ7a-0003Ue-8I for help-gnu-emacs@gnu.org; Thu, 08 Sep 2005 13:23:34 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1EDPzb-0001HC-8K for help-gnu-emacs@gnu.org; Thu, 08 Sep 2005 19:15:19 +0200 Original-Received: from 207.167.42.60 ([207.167.42.60]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 08 Sep 2005 19:15:19 +0200 Original-Received: from ihs_4664 by 207.167.42.60 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 08 Sep 2005 19:15:19 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-To: help-gnu-emacs@gnu.org Original-Lines: 49 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: 207.167.42.60 User-Agent: Mozilla Thunderbird 0.9 (X11/20041105) X-Accept-Language: en-us, en In-Reply-To: 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:29336 Archived-At: 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