* wesnoth-mode.texi: Remove Key Index chapter references.
[wesnoth-mode.git] / wesnoth-mode.texi
blob330c4bf789e721132dca88c3f0fd8d56e49587b9
1 \input texinfo
2 @c %**start of header
3 @setfilename wesnoth-mode.info
4 @settitle Wesnoth Mode Manual
6 @set VERSION 1.3.3
7 @set DATE October 2008
9 @dircategory Emacs
10 @direntry
11 * Wesnoth Mode: (wesnoth-mode).         Major-mode for editing WML
12 @end direntry
14 @c Contact information
15 @set MAINTAINERSITE @uref{http://www.wesnoth.org/forum/viewtopic.php?t=13798}
16 @set AUTHOR Chris Mann
17 @c %**end of header
18 @finalout
20 @copying
21 This manual is for Wesnoth Mode (version @value{VERSION}).
23 Copyright @copyright{} 2008 Chris Mann
25 @quotation
26 This program is free software; you can redistribute it and/or modify it
27 under the terms of the GNU General Public License as published by the
28 Free Software Foundation; either version 2 of the License, or (at your
29 option) any later version.
31 This program is distributed in the hope that it will be useful, but
32 WITHOUT ANY WARRANTY; without even the implied warranty of
33 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
34 General Public License for more details.
36 You should have received a copy of the GNU General Public License along
37 with this program; if not, write to the Free Software Foundation, Inc.,
38 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
39 @end quotation
40 @end copying
42 @titlepage
43 @title Wesnoth Mode Manual
44 @subtitle Version @value{VERSION}
45 @author by Chris Mann
47 @page
49 @vskip 0pt plus 1fill
50 @insertcopying
51 @end titlepage
53 @contents
54 @ifnottex
55 @node Top, Introduction, (dir), (dir)
56 @top Wesnoth Mode Manual
58 @insertcopying
59 @end ifnottex
61 @menu
62 * Introduction::                Getting started
63 * Basic Usage::                  Moving around within WML
64 * Inserting Elements::          Insertion and completion of elements
65 * Checking WML::                Checking WML for common problems
66 * Customisation::               Available customisation options
68 @detailmenu
69  --- Detailed Node Listing ---
71 Introduction
73 * Summary::                     Introduction to Wesnoth Mode
74 * Getting Started::             How to start Wesnoth Mode
76 Basic Usage
78 * Indentation::                 Indentation usage and styles
79 * Navigation::                  Common WML navigation
81 Inserting Elements
83 * Standard Completion::         Completion commands and functionality
84 * Tab-Completion::              Element tab-completion
85 * Wrapping Elements::           Wrapping elements around sets of tags
86 * Missing Elements::            Finding and inserting missing elements
88 Checking WML
90 * Usage and Capabilities::      What to expect when checking WML
92 Customisation
94 * Indentation::                 Customising WML indentation
95 * Wesnoth Update::              Using and configuring Wesnoth Update
96 * Macro Definitions::           Making project-local macros known
98 @end detailmenu
99 @end menu
101 @node Introduction, Basic Usage, Top, Top
102 @chapter Introduction
104 @menu
105 * Summary::                     Introduction to Wesnoth Mode
106 * Getting Started::             How to start Wesnoth Mode
107 @end menu
109 @node Summary, Getting Started, Introduction, Introduction
110 @section Summary
112 Wesnoth Mode is a major mode for Emacs which assists in the editing of
113 the markup language extensively used in Wesnoth, a turn-based fantasy
114 strategy game.  From the Wesnoth Wiki: "The Wesnoth Markup Language
115 (WML) is used to code almost everything in Wesnoth, including scenarios,
116 units, savefiles, and the user interface layout."
117 @footnote{@uref{http://www.wesnoth.org/wiki/ReferenceWML}}
119 Wesnoth Mode is supported under GNU Emacs 21 onwards and (with some
120 minor limitations) XEmacs 21.  Wesnoth Mode adds support for syntax
121 highlighting, automatic indentation, context-sensitive completion,
122 checking and much more when editing WML.
124 This documentation attempts to provide a comprehensive guide to
125 functionality available within Wesnoth Mode @value{VERSION}, and assumes
126 you are familiar with basic usage, terminology and customisation of
127 Emacs.  For more information, please refer to the Emacs
128 manual. @footnote{@uref{http://www.gnu.org/software/emacs/manual/html_node/emacs/}}
130 @node Getting Started, , Summary, Introduction
131 @section Getting Started
133 To use Wesnoth Mode, add the following to your @file{.emacs}:
134 @lisp
135 (add-to-list 'load-path "path/to/wesnoth-mode")
136 (autoload 'wesnoth-mode "wesnoth-mode" "Major mode for editing WML." t)
137 @end lisp
138 Optionally adding:
139 @lisp
140 (add-to-list 'auto-mode-alist '("\\.cfg\\'" . wesnoth-mode))
141 @end lisp
142 to automatically load Wesnoth Mode for all files with a `.cfg'
143 extension.
145 Wesnoth Mode can be activated as the current major-mode for a buffer via
146 @kbd{M-x wesnoth-mode}.
148 The latest version of Wesnoth Mode along with release notes can be found
149 at @uref{http://www.wesnoth.org/forum/viewtopic.php?t=13798}.
151 @node Basic Usage, Inserting Elements, Introduction, Top
152 @chapter Basic Usage
154 @menu
155 * Indentation::                     Common WML navigation
156 * Navigation::                      Moving backward and forward across elements
157 @end menu
159 @node Indentation, Navigation, Basic Usage, Basic Usage
160 @section Indentation
164 @node Navigation,  , Indentation, Basic Usage
165 @section Navigation
167 Emacs provides many powerful built-in navigation commands which are
168 ideal for editing WML.  Common navigation commands, such as @kbd{C-n},
169 @kbd{C-s}, and (in recent Emacsen) @kbd{M-g g}, will behave as usual
170 within Wesnoth Mode.  However, some navigation commands have been
171 added or adjusted.
173 Next and previous opening elements can be navigated using @kbd{C-M-e}
174 and @kbd{C-M-a}, respectively.  In each case, point will be positioned
175 immediately before the element.  When no more elements are available in
176 that direction, point will not move.
178 Moving to the matching element in a pair or locating the parent element
179 (depending on the position of point) can be performed via @kbd{C-c C-o}.
180 When point is on the same line as an opening element, such as an opening
181 tag or opening preprocessor statement it will be moved to the start of
182 the matching closing element.  Otherwise, the jump will position point
183 at the beginning of the corresponding opening element.
185 @node Inserting Elements, Checking WML, Basic Usage, Top
186 @chapter Inserting Elements
188 @menu
189 * Standard Completion::         Completion commands and functionality
190 * Tab-Completion::              Element tab-completion
191 * Wrapping Elements::           Wrapping elements around sets of tags
192 * Missing Elements::            Finding and inserting missing elements
193 @end menu
195 @node Standard Completion, Tab-Completion, Inserting Elements, Inserting Elements
196 @section Standard Completion
198 Tags can be inserted via @kbd{C-c C-t} and alternatively @kbd{M-TAB}
199 (when this is not shadowed by the Window Manager, etc.) which will
200 prompt for the tag to add.  The tag entered into the minibuffer prompt
201 and its matching closing tag will be inserted and point positioned
202 between.
204 Attributes can be inserted via @kbd{C-c C-a}.  Any attribute entered at
205 the prompt will be inserted along with the `=', with point immediately
206 following.
208 Both tag and attribute completion is context-sensitive.  If an element
209 is available in WML and not listed for completion, it can be added to
210 the `addition file'.  See @ref{Wesnoth Update} for more information.
212 Macro insertion can be performed via @kbd{C-c C-m}.  Any arguments known
213 to be required for the macro will be prompted and inserted in order.
214 Insertion will be aborted if no value for an argument is provided.  When
215 within a macro definition, the arguments for the current macro are also
216 available for completion.  Any project-local or custom macros can be
217 made available for completion by opening the file in which they are
218 defined.  For information, see @ref{Macro Definitions}.
220 Preprocessor statements are available for insertion via @kbd{C-c C-p}.
221 Closing elements for preprocessor statements will be automatically
222 inserted where possible, with point positioned between.  Otherwise,
223 point will be placed immediately after the inserted text.
225 @node Tab-Completion, Wrapping Elements, Standard Completion, Inserting Elements
226 @section Tab-Completion
228 Completion can also be performed immediately within the buffer via
229 @kbd{TAB} on a partial element.  For example:
230 @example
231 [scenario]
232     vil-!-
233 @end example
234 Where @code{-!-} is the position of point.  Using @kbd{TAB} in the
235 example will complete to @code{vil} to @code{village_gold=}.  Tags,
236 macros and preprocessor statements can be completed similarly.  When the
237 current line does not contain a partially completed element, @kbd{TAB}
238 will perform indentation on the current line.
240 When there is more than one possible completion, a minibuffer prompt
241 will be provided, with the partial element entered.  @kbd{TAB} can be
242 used here to perform completion.  If multiple matches are available,
243 completion will be performed up to the smallest common substring with
244 further completion available via the minubuffer prompt.  When no matches
245 are found for the partial element, completion will not be prompted.
247 When completing opening preprocessor statements and tags, Wesnoth Mode
248 will also attempt to insert a matching closing element if one is not
249 already available, acting in much the same way as if the element was
250 added via the minibuffer prompt.  However, if an matching closing
251 element is available, only the element at point will be completed.
253 A numeric argument can be provided when performing tab-completion of
254 opening elements to wrap around the next @i{n} blocks.  For
255 example, to wrap the completed opening and closing pair around the next
256 three blocks, @kbd{C-u 3 TAB} can be used.  See @ref{Wrapping Elements}
257 for more information.
259 @node Wrapping Elements, Missing Elements, Tab-Completion, Inserting Elements
260 @section Wrapping Elements
261 When inserting tags and some preprocessor statements, either via their
262 respective insertion command or via @kbd{TAB}, an optional numeric
263 argument can be provided to specify the number of `blocks' to wrap the
264 element around.  For example:
266 @example
267 [multiplayer]
268  -!-[part]
269         ...
270     [/part]
271     [part]
272         ...
273     [/part]
274     [event]
275         ...
276 @end example
278 Where point is at the position indicated by @code{-!-}.  A pair of
279 @code{story} tags can be inserted around both existing @code{part} tags
280 using @kbd{C-u 2 C-c C-t story}.  When the number of blocks specified to
281 wrap around exceeds the number of blocks available, Wesnoth Mode will
282 only wrap around the number of available so that the nesting of elements
283 is correct.
285 @node Missing Elements, , Wrapping Elements, Inserting Elements
286 @section Missing Elements
287 Missing closing elements can be inserted using @kbd{C-c C-/}.  By
288 default, this will insert the first missing closing element found in the
289 current buffer at point.  If all elements appear to be matched or if
290 there is an excess of closing tags, a notification will be displayed and
291 no element will be inserted.
293 @node Checking WML, Customisation, Inserting Elements, Top
294 @chapter Checking WML
296 @menu
297 * Usage and Capabilities::      What to expect when checking WML
298 @end menu
300 @node Usage and Capabilities, , Checking WML, Checking WML
301 @section Usage and Capabilities
303 Checking WML in the current buffer can be performed using @kbd{C-c C-c},
304 with a summary of all warnings found reported in a separate buffer.
305 Point can be jumped to the next and previous warning using @kbd{C-c C-f}
306 (or @kbd{C-x `}) and @kbd{C-c C-b}, respectively.  For visibility,
307 warnings will be underlined in red by default.  @i{Note: Warning
308 underlines may not be available in XEmacs.}
310 The WML checking built-in to Wesnoth Mode is not intended to be an
311 alternative to tools such as `wmllint', but may often be a convenient
312 substitute while editing WML.
314 The following conditions can be detected by WML checking in Wesnoth
315 Mode:
316 @itemize
317 @item Correct nesting of tags and preprocessor statements
318 @item Known macro definitions @footnote{see @ref{Macro Definitions}}
319 @item Availability of elements within the given context
320 @item Arguments are given to preprocessor statements when required
321 @item Attributes have a value assigned
322 @item Corresponding FOREACH..NEXT pairs
323 @end itemize
325 WML checking is specific to the version of WML known by Wesnoth Mode.
326 See @ref{Wesnoth Update} for more information.
328 @node Customisation, , Checking WML, Top
329 @chapter Customisation
331 @menu
332 * Modifying Indentation::       Customising WML indentation
333 * Wesnoth Update::              Using and configuring Wesnoth Update
334 * Macro Definitions::           making project-local macros known
335 @end menu
337 @node Modifying Indentation, Wesnoth Update, Customisation, Customisation
338 @section Modifying Indentation
340 The style of indentation can be customised using
341 @code{wesnoth-indent-savefile}.  The default value is @code{t},
342 which results in all children being indented a level deeper than their
343 parent.  When set to @code{nil}, children will be indented to the same
344 level as their parent element.  This option is provided only for
345 consistency when editing (very) old WML.  It is recommended that this be
346 non-nil for all new WML.
348 @code{wesnoth-indent-preprocessor-bol} controls how preprocessor
349 statements should be indented.  If non-nil, all preprocessor statements
350 will be indented to the beginning of the line.  Otherwise, preprocessor
351 statements will be indented as to the level indicated by its context.
353 By default, Wesnoth Mode will attempt indentation of the current line
354 and create a newline and when @kbd{RET} or @kbd{C-j} are used.
355 @code{wesnoth-auto-indent-flag} controls whether Wesnoth Mode will
356 attempt to indent the current line automatically.  Setting this to
357 @code{nil} will prevent automatic indentation.  Note that this does not
358 affect the behaviour of @kbd{C-j} performing indentation following the
359 newline; this only determines whether indentation will be automatically
360 performed on the current line.
362 The following can be used to change @kbd{RET} to automatically indent the
363 newline:
364 @example
365 (add-hook 'wesnoth-mode-hook
366   '(lambda ()
367     (define-key wesnoth-mode-map (kbd ``C-m'') 'wesnoth-newline-and-indent)))
368 @end example
370 @code{wesnoth-base-indent} controls the depth of indentation for each
371 level.  Its value should be an integer.  This is set to `4' by default,
372 which is the convention used when indenting WML.
374 By default, Wesnoth Mode will use spaces for indentation.  Tabs can instead be used with the following:
375 @example
376 (add-hook 'wesnoth-mode-hook
377   '(lambda ()
378     (setq indent-tabs-mode t
379           tab-width wesnoth-base-indent)))
380 @end example
382 @code{wesnoth-warning-face} is the face used to display the overlay for
383 warnings detected when checking WML (See @ref{Checking WML}).  By
384 default this is a red underline.  @i{Note: use of this face may not be supported
385 under XEmacs.}
387 @node Wesnoth Update, Macro Definitions, Modifying Indentation, Customisation
388 @section Wesnoth Update
390 Wesnoth Update controls the known WML data for Wesnoth Mode.  To update
391 this information, three variables need to be set appropriately:
392 @code{wesnoth-root-directory}, @code{wesnoth-update-output-directory}
393 and @code{wesnoth-addition-file}.
395 @code{wesnoth-root-directory} should be the path to the root directory
396 of a Wesnoth installation or Wesnoth source code.  Wesnoth Update will
397 search recursively in this directory for WML, using the information
398 found to provide context-sensitive completion and WML checking.
400 @code{wesnoth-update-output-directory} specifies the path to store the
401 WML data found.  This path should be within the @code{load-path}, and
402 preferably, in the same directory as Wesnoth Mode.
404 @code{wesnoth-addition-file} specifies the `addition file' to use.  An
405 addition file is an outline of a valid WML file which is processed for
406 additional element data.  This should be set as the path a suitable
407 addition file.  A sample addition file is included with Wesnoth Mode.
409 For example:
410 @example
411 (setq wesnoth-root-directory "/usr/local/share/wesnoth/"
412       wesnoth-addition-file
413       "~/.emacs.d/wesnoth-mode/wesnoth-wml-additions.cfg"
414       wesnoth-update-output-directory "~/.emacs.d/wesnoth-mode/")
415 @end example
417 Once set, @kbd{M-x wesnoth-update} will generate and load a new cache of
418 WML data ready for use for the current and future sessions.  @i{Note:
419 @code{wesnoth-update} may take some time to run.}
421 @node Macro Definitions, , Wesnoth Update, Customisation
422 @section Macro Definitions
424 While built-in macros are always available, local macro definitions are
425 automatically scanned and made known to Wesnoth Mode for each WML file
426 which is loaded in the session. @kbd{C-c C-u} can be used to update the
427 known macro definitions for any buffer which has since been
428 modified. (Note that this is not required when the macro is defined in
429 the WML file currently being edited as such definitions will be
430 automatically updated when needed.)  @kbd{C-u C-c C-u} can be used to
431 clear known local macro definitions.
433 @bye
435 @c Local Variables: 
436 @c mode: texinfo
437 @c TeX-master: t
438 @c End: