From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Lute Kamstra Newsgroups: gmane.emacs.devel Subject: Re: Documenting define-generic-mode. Date: Thu, 28 Apr 2005 15:50:54 +0200 Message-ID: <87ekcvxb5t.fsf@xs4all.nl> References: <87mzrqpzye.fsf@xs4all.nl> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1114696376 20522 80.91.229.2 (28 Apr 2005 13:52:56 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 28 Apr 2005 13:52:56 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Apr 28 15:52:50 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DR9Pq-00070g-Ls for ged-emacs-devel@m.gmane.org; Thu, 28 Apr 2005 15:50:55 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DR9Vz-0007FJ-0t for ged-emacs-devel@m.gmane.org; Thu, 28 Apr 2005 09:57:15 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DR9VR-00078D-QP for emacs-devel@gnu.org; Thu, 28 Apr 2005 09:56:41 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DR9VR-00077q-31 for emacs-devel@gnu.org; Thu, 28 Apr 2005 09:56:41 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DR9VQ-00077m-Ue for emacs-devel@gnu.org; Thu, 28 Apr 2005 09:56:40 -0400 Original-Received: from [194.109.24.35] (helo=smtp-vbr15.xs4all.nl) by monty-python.gnu.org with esmtp (Exim 4.34) id 1DR9Tv-0001P6-Gc; Thu, 28 Apr 2005 09:55:07 -0400 Original-Received: from pijl (a80-127-67-124.adsl.xs4all.nl [80.127.67.124]) by smtp-vbr15.xs4all.nl (8.12.11/8.12.11) with ESMTP id j3SDoth4004207; Thu, 28 Apr 2005 15:50:55 +0200 (CEST) (envelope-from Lute.Kamstra@xs4all.nl) Original-Received: from lute by pijl with local (Exim 3.36 #1 (Debian)) id 1DR9Pq-0004pN-00; Thu, 28 Apr 2005 15:50:54 +0200 Original-To: rms@gnu.org In-Reply-To: (Richard Stallman's message of "Sat, 23 Apr 2005 18:24:00 -0400") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) Original-Lines: 101 X-Virus-Scanned: by XS4ALL Virus Scanner X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:36479 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:36479 Richard Stallman writes: > Shall I document define-generic-mode in lispref/modes.texi? I think > its own node "Generic Modes", right after the node "Derived Modes", > would be appropriate. > > You can try drafting something, and I will tell you what I think of > it. There you go... Lute. Index: lispref/modes.texi =================================================================== RCS file: /cvsroot/emacs/emacs/lispref/modes.texi,v retrieving revision 1.98 diff -c -r1.98 modes.texi *** lispref/modes.texi 28 Apr 2005 11:32:54 -0000 1.98 --- lispref/modes.texi 28 Apr 2005 13:49:05 -0000 *************** *** 103,108 **** --- 103,110 ---- * Mode Help:: Finding out how to use a mode. * Derived Modes:: Defining a new major mode based on another major mode. + * Generic Modes:: Defining a simple major mode that supports + comment syntax and Font Lock mode. * Mode Hooks:: Hooks run at the end of major mode functions. @end menu *************** *** 798,803 **** --- 800,806 ---- @node Derived Modes @subsection Defining Derived Modes + @cindex derived mode It's often useful to define a new major mode in terms of an existing one. An easy way to do this is to use @code{define-derived-mode}. *************** *** 860,865 **** --- 863,918 ---- @code{define-derived-mode} does that automatically. @end defmac + @node Generic Modes + @subsection Generic Modes + @cindex generic mode + + @dfn{Generic modes} are simple major modes with basic support for + comment syntax and Font Lock mode. They are primarily useful for + configuration files. The macro @code{define-generic-mode} defines a + generic mode. See the file @file{generic-x.el} for some examples of + the use of @code{define-generic-mode}. + + @defmac define-generic-mode mode comment-list keyword-list font-lock-list auto-mode-list function-list &optional docstring &rest custom-keyword-args + This macro creates a new generic mode. The argument @var{mode} is the + name of the command for the generic mode; it need not be quoted. The + optional argument @var{docstring} is the documentation for the mode + command. If you do not supply it, a default documentation string will + be used instead. + + @var{comment-list} is a list, whose entries are either a single + character, a one or two character string or a cons pair. If the entry + is a character or a string, it is added to the mode's syntax table + with ``comment starter'' syntax. If the entry is a cons pair, the + elements of the pair are considered to be ``comment starter'' and + ``comment ender'' respectively. (The latter should be @code{nil} if + you want comments to end at the end of the line.) Note that Emacs has + limitations regarding comment characters. @xref{Syntax Tables}. + + @var{keyword-list} is a list of keywords to highlight with + @code{font-lock-keyword-face}. Each keyword should be a string. + @var{font-lock-list} is a list of additional expressions to highlight. + Each entry in this list should have the same form as an entry in + @code{font-lock-keywords}. @xref{Search-based Fontification}. + + @var{auto-mode-list} is a list of regular expressions to add to the + variable @code{auto-mode-alist}. These regular expressions are added + as soon as @code{define-generic-mode} is called. + + @var{function-list} is a list of functions to call to do some + additional setup. The mode command calls these functions just before + it runs the mode hook. + + The optional @var{custom-keyword-args} are pairs of keywords and + values. They are passed to the generated @code{defcustom} form of the + mode hook variable @var{mode}-hook. The default value for the + @samp{:group} keyword is @var{mode} without the possible trailing + @samp{-mode}. Don't use this default group name unless you have + written a @code{defgroup} to define that group properly (@pxref{Group + Definitions}). You can specify keyword arguments without specifying a + docstring. + @end defmac + @node Mode Hooks @subsection Mode Hooks