Mercurial > emacs
comparison man/major.texi @ 74741:53b637f954f2
(Choosing Modes): Describe match-function elements for
magic-mode-alist.
author | Kim F. Storm <storm@cua.dk> |
---|---|
date | Tue, 19 Dec 2006 09:14:00 +0000 |
parents | dc2d5a6655a3 |
children | eda5cae57c32 |
comparison
equal
deleted
inserted
replaced
74740:46f8a3942acb | 74741:53b637f954f2 |
---|---|
100 @var{regexp} and searches the list again for another match. | 100 @var{regexp} and searches the list again for another match. |
101 | 101 |
102 @vindex magic-mode-alist | 102 @vindex magic-mode-alist |
103 Sometimes the major mode is determined from the way the file's text | 103 Sometimes the major mode is determined from the way the file's text |
104 begins. The variable @code{magic-mode-alist} controls this. Its value | 104 begins. The variable @code{magic-mode-alist} controls this. Its value |
105 is a list of elements of this form: | 105 is a list of elements of these forms: |
106 | 106 |
107 @example | 107 @example |
108 (@var{regexp} . @var{mode-function}) | 108 (@var{regexp} . @var{mode-function}) |
109 (@var{match-function} . @var{mode-function}) | |
109 @end example | 110 @end example |
110 | 111 |
111 @noindent | 112 @noindent |
112 This looks like an element of @code{auto-mode-alist}, but it doesn't work | 113 The first form looks like an element of @code{auto-mode-alist}, but it |
113 the same: this @var{regexp} is matched against the text at the start | 114 doesn't work the same: this @var{regexp} is matched against the text |
114 of the buffer, not against the file name. @code{magic-mode-alist} | 115 at the start of the buffer, not against the file name. Likewise, the |
115 takes priority over @code{auto-mode-alist}. | 116 second form calls @var{match-function} at the beginning of the buffer, |
117 and if the function returns non-@code{nil}, the @var{mode-function} is | |
118 called. @code{magic-mode-alist} takes priority over | |
119 @code{auto-mode-alist}. | |
116 | 120 |
117 You can specify the major mode to use for editing a certain file by | 121 You can specify the major mode to use for editing a certain file by |
118 special text in the first nonblank line of the file. The | 122 special text in the first nonblank line of the file. The |
119 mode name should appear in this line both preceded and followed by | 123 mode name should appear in this line both preceded and followed by |
120 @samp{-*-}. Other text may appear on the line as well. For example, | 124 @samp{-*-}. Other text may appear on the line as well. For example, |