Updated the WML emacs mode to the new 1.3.5 upstream version.
This commit is contained in:
parent
4cc1b6c931
commit
9fce499eef
5 changed files with 302 additions and 100 deletions
|
@ -19,10 +19,10 @@
|
|||
;; MA 02139, USA.
|
||||
|
||||
;;; Description:
|
||||
;; wesnoth-mode is a major mode for Emacs which assists in the editing
|
||||
;; of Wesnoth Markup Language (WML) files. Currently, this major-mode
|
||||
;; features syntax highlighting support, automatic indentation,
|
||||
;; context-sensitive completion and WML checking.
|
||||
;; wesnoth-mode is a major mode for Emacs which assists in the editing of
|
||||
;; Wesnoth Markup Language (WML) files. Features of wesnoth-mode include
|
||||
;; syntax highlighting support, automatic indentation, context-sensitive
|
||||
;; completion and WML checking.
|
||||
|
||||
;;; Commentary:
|
||||
;; Add the following to your .emacs:
|
||||
|
@ -33,9 +33,20 @@
|
|||
;; to automatically load wesnoth-mode for all files ending in '.cfg'.
|
||||
|
||||
;;; History:
|
||||
;; 1.3.5
|
||||
;; * Added navigation commands: C-M-n and C-M-p can be used to move to the
|
||||
;; next and previous children of the current parent element, respectively.
|
||||
;; C-M-u and C-M-d can be used to move to the parent element and the next
|
||||
;; child element, respectively.
|
||||
;; * Added commands for structured editing: C-M-k kills the block at point.
|
||||
;; C-M-SPC sets the mark to the position of the end of the block at point.
|
||||
;; * Fixed a bug where the parent tag would be unknown if a macro was defined
|
||||
;; between point and the position of the parent element.
|
||||
;; * Fixed a bug where an incorrectly formatted closing tag could be inserted
|
||||
;; in some circumstances.
|
||||
;; 1.3.4a
|
||||
;; * #ifdef, #ifndef preprocessor statements now indent their contents relative
|
||||
;; to themselves when `wesnoth-indent-preprocessor-bol' is nil.
|
||||
;; * #ifdef, #ifndef preprocessor statements now indent their contents
|
||||
;; relative to themselves when `wesnoth-indent-preprocessor-bol' is nil.
|
||||
;; * Fixed a bug which could prevent element completion immediately within a
|
||||
;; preprocessor statement.
|
||||
;; 1.3.4
|
||||
|
@ -142,8 +153,8 @@
|
|||
;; `wesnoth-jump-backward', `wesnoth-jump-forward' to
|
||||
;; `wesnoth-indent-withtags-inline', `wesnoth-indent-default-inline' and
|
||||
;; `wesnoth-backward-tag', `wesnoth-forward-tag', respectively.
|
||||
;; * Fixed a bug in indentation where content was needed between elements pairs
|
||||
;; for indentation to work.
|
||||
;; * Fixed a bug in indentation where content was needed between elements
|
||||
;; pairs for indentation to work.
|
||||
;; * Fixed `wesnoth-newline-and-indent' ignoring the state of
|
||||
;; `wesnoth-auto-indent-flag'.
|
||||
;; * Fixed `{...}' and `#endif' not font-locking correctly.
|
||||
|
@ -178,7 +189,7 @@
|
|||
(require 'wesnoth-update)
|
||||
(require 'wesnoth-wml-data)
|
||||
|
||||
(defconst wesnoth-mode-version "1.3.4a"
|
||||
(defconst wesnoth-mode-version "1.3.5"
|
||||
"The current version of `wesnoth-mode'.")
|
||||
|
||||
(defgroup wesnoth-mode nil "Wesnoth-mode access"
|
||||
|
@ -208,7 +219,8 @@ level as their parent.")
|
|||
:group 'wesnoth-mode)
|
||||
|
||||
(defconst wesnoth-preprocessor-regexp
|
||||
"[\t ]*#\\(enddef\\|define \\|e\\(lse\\|nd\\(\\(de\\|i\\)f\\)\\)\\|\\(ifn?\\|un\\)def \\)"
|
||||
"[\t ]*#\\(enddef\\|define \\|e\\(lse\\|nd\\(\\(de\\|i\\)f\\)\\)\
|
||||
\\|\\(ifn?\\|un\\)def \\)"
|
||||
"Regular expression to match all preprocessor statements.")
|
||||
|
||||
(defconst wesnoth-preprocessor-opening-regexp
|
||||
|
@ -239,6 +251,12 @@ level as their parent.")
|
|||
(let ((map (make-sparse-keymap)))
|
||||
(define-key map (kbd "C-M-a") 'wesnoth-backward-element)
|
||||
(define-key map (kbd "C-M-e") 'wesnoth-forward-element)
|
||||
(define-key map (kbd "C-M-n") 'wesnoth-forward-list)
|
||||
(define-key map (kbd "C-M-p") 'wesnoth-backward-list)
|
||||
(define-key map (kbd "C-M-d") 'wesnoth-down-list)
|
||||
(define-key map (kbd "C-M-u") 'wesnoth-backward-up-list)
|
||||
(define-key map (kbd "C-M-k") 'wesnoth-kill-block)
|
||||
(define-key map (kbd "C-M-SPC") 'wesnoth-mark-block)
|
||||
(define-key map (kbd "C-m") 'wesnoth-newline)
|
||||
(define-key map (kbd "C-j") 'wesnoth-newline-and-indent)
|
||||
(define-key map (kbd "C-c C-c") 'wesnoth-check-wml)
|
||||
|
@ -290,7 +308,8 @@ level as their parent.")
|
|||
;; pre-processor statements.
|
||||
(defvar wesnoth-syntactic-keywords
|
||||
(list
|
||||
'("\\([\t ]*\\(#\\(?:define \\|e\\(?:lse\\|nd\\(?:\\(?:de\\|i\\)f\\)\\)\\|\\(?:ifn?\\|un\\)def \\)\\)\\)" 1 "w"))
|
||||
'("\\([\t ]*\\(#\\(?:define \\|e\\(?:lse\\|nd\\(?:\\(?:de\\|i\\)f\\)\\)\\|\
|
||||
\\(?:ifn?\\|un\\)def \\)\\)\\)" 1 "w"))
|
||||
"Syntactic keywords for preprocessor statements within `wesnoth-mode'.")
|
||||
|
||||
(defvar wesnoth-font-lock-keywords
|
||||
|
@ -396,7 +415,8 @@ of the element."
|
|||
("\\[\\+?[^/]+?\\]" . tag-opening)
|
||||
("\\[/.+?\\]" . tag-closing)
|
||||
("\\(\\w\\|_\\)+[\t ]*=" . attribute)
|
||||
("#\\(enddef\\|define \\|e\\(lse\\|nd\\(\\(de\\|i\\)f\\)\\)\\|\\(ifn?\\|un\\)def \\)"
|
||||
("#\\(enddef\\|define \\|e\\(lse\\|nd\\(\\(de\\|i\\)f\\)\\)\\|\
|
||||
\\(ifn?\\|un\\)def \\)"
|
||||
. preprocessor)
|
||||
("#.*$" . comment)
|
||||
("[^\t ]+") . nil)))
|
||||
|
@ -418,7 +438,8 @@ of the element."
|
|||
("\\[/\\(\\w\\|_\\)*$" . tag-closing)
|
||||
("\\[\\+?\\(\\w\\|_\\)*$" . tag-opening)
|
||||
("^[\t ]*\\(\\w\\|_\\)+$" . attribute)
|
||||
("[\t ]*#\\(enddef\\|define \\|e\\(lse\\|nd\\(\\(de\\|i\\)f\\)\\)\\|\\(ifn?\\|un\\)def \\)"
|
||||
("[\t ]*#\\(enddef\\|define \\|e\\(lse\\|nd\
|
||||
\\(\\(de\\|i\\)f\\)\\)\\|\\(ifn?\\|un\\)def \\)"
|
||||
. nil) ; not a partial match
|
||||
("[\t ]*#\\w*$" . preprocessor))))
|
||||
(catch 'result
|
||||
|
@ -494,9 +515,8 @@ Otherwise, return a string containing the name of the parent tag."
|
|||
(point))))
|
||||
(end-of-line))
|
||||
(while (and (> depth 0)
|
||||
(search-backward-regexp (wesnoth-element t)
|
||||
(point-min) t))
|
||||
(if (string-match "[\t ]*\\[/" (match-string 0))
|
||||
(search-backward-regexp (wesnoth-element t) (point-min) t))
|
||||
(if (string-match "[\t ]*\\[/\\|#enddef" (match-string 0))
|
||||
(setq depth (1+ depth))
|
||||
(setq depth (1- depth))))
|
||||
(beginning-of-line)
|
||||
|
@ -512,7 +532,8 @@ Otherwise, return a string containing the name of the parent tag."
|
|||
(string= (match-string 0) "{")
|
||||
(goto-char start-point)
|
||||
(not (and (search-backward parent (point-min) t)
|
||||
(search-backward-regexp "[}{]" (point-min) t)
|
||||
(search-backward-regexp "[}{]" (point-min)
|
||||
t)
|
||||
(string= (match-string 0) "{")))))
|
||||
(cons t position)
|
||||
(cons (substring parent 1 (1- (length parent))) position))))))))
|
||||
|
@ -590,7 +611,8 @@ If COMPLETEP is non-nil, attempt to complete preprocessor at point."
|
|||
(when preprocessor
|
||||
(unless (string= "#" (substring preprocessor 0 1))
|
||||
(setq preprocessor (concat "#" preprocessor)))
|
||||
(when (string-match "#\\(define\\|ifn?def\\|undef\\)" preprocessor)
|
||||
(when (string-match "#\\(define\\|ifn?def\\|undef\\)"
|
||||
preprocessor)
|
||||
(setq preprocessor (concat preprocessor " ")))
|
||||
(when partial
|
||||
(delete-region (nth 1 details) (nth 2 details)))
|
||||
|
@ -812,7 +834,11 @@ TAGNAME is the name of the tag to be inserted."
|
|||
(if (string= tagname "#define ")
|
||||
"#enddef"
|
||||
"#endif"))
|
||||
(wesnoth-insert-element-separately "[/" tagname "]"))
|
||||
(wesnoth-insert-element-separately "[/" (if (string-match "^+"
|
||||
tagname)
|
||||
(substring tagname 1)
|
||||
tagname)
|
||||
"]"))
|
||||
(indent-region start (point) nil))
|
||||
(unless end
|
||||
(forward-line 1)))
|
||||
|
@ -858,7 +884,12 @@ for the matching tag."
|
|||
(when match
|
||||
(if (string= (substring match 0 1) "[")
|
||||
(wesnoth-insert-element-separately
|
||||
"[/" (substring match 1 (1- (length match))) "]")
|
||||
"[/"
|
||||
(let ((tagname (substring match 1 (1- (length match)))))
|
||||
(if (string-match "^+" tagname)
|
||||
(substring tagname 1)
|
||||
tagname))
|
||||
"]")
|
||||
(wesnoth-insert-element-separately
|
||||
(cdr (assoc match '(("#define " . "#enddef")
|
||||
("#ifndef " . "#endif")
|
||||
|
@ -951,7 +982,8 @@ BOUND is the bound to be passed to the search function.
|
|||
If SKIP is non-nil, skip the first element and continue from there."
|
||||
(let ((depth 1))
|
||||
(when (and (or (and (numberp skip) (forward-line skip))
|
||||
(funcall search-function (wesnoth-element) (funcall bound) t))
|
||||
(funcall search-function (wesnoth-element)
|
||||
(funcall bound) t))
|
||||
(or skip (not (string-match search-string (match-string 0)))))
|
||||
(while (and (> depth 0)
|
||||
(funcall search-function (wesnoth-element)
|
||||
|
@ -1063,7 +1095,8 @@ CONTEXT represents the type of element which precedes the current element."
|
|||
(setq cur-indent ref-indent)
|
||||
(if (or (and wesnoth-indent-savefile
|
||||
(or (looking-at "[\t ]*{NEXT ")
|
||||
(and (not (looking-at (wesnoth-element-closing t)))
|
||||
(and (not
|
||||
(looking-at (wesnoth-element-closing t)))
|
||||
(not (looking-at "[\t ]*{NEXT ")))))
|
||||
(looking-at (wesnoth-element-opening t))
|
||||
(looking-at "[\t ]*{FOREACH "))
|
||||
|
@ -1073,11 +1106,12 @@ CONTEXT represents the type of element which precedes the current element."
|
|||
(if (and (looking-at "^[\t ]*#else")
|
||||
(not wesnoth-indent-preprocessor-bol))
|
||||
(setq cur-indent (- ref-indent wesnoth-base-indent))
|
||||
(if (or (looking-at (concat "^[\t ]*\\(\\[/\\|\\#enddef"
|
||||
(if (not wesnoth-indent-preprocessor-bol)
|
||||
"\\|#endif"
|
||||
"")
|
||||
"\\)"))
|
||||
(if (or (looking-at
|
||||
(concat "^[\t ]*\\(\\[/\\|\\#enddef"
|
||||
(if (not wesnoth-indent-preprocessor-bol)
|
||||
"\\|#endif"
|
||||
"")
|
||||
"\\)"))
|
||||
(and (not wesnoth-indent-savefile)
|
||||
(not (looking-at (wesnoth-element-opening t)))
|
||||
(not (looking-at "[\t ]*{FOREACH "))))
|
||||
|
@ -1097,7 +1131,8 @@ POSITION is the initial cursor position."
|
|||
(wesnoth-find-macro-definitions))))
|
||||
(unless (equal (car defblocks) 'none)
|
||||
(dolist (element defblocks)
|
||||
(when (= (cadr (sort (append (mapcar 'marker-position (cadr element))
|
||||
(when (= (cadr (sort (append (mapcar 'marker-position
|
||||
(cadr element))
|
||||
(list position)) '>)) position)
|
||||
(setq depth (max (car element) depth)))))
|
||||
depth)))
|
||||
|
@ -1156,8 +1191,9 @@ determine the context."
|
|||
(and (search-backward-regexp
|
||||
elements (point-min) t)
|
||||
(progn
|
||||
(while (save-match-data
|
||||
(looking-at "^[\t ]*\\[[^/].+\\]\\[/.+\\]"))
|
||||
(while
|
||||
(save-match-data
|
||||
(looking-at "^[\t ]*\\[[^/].+\\]\\[/.+\\]"))
|
||||
(search-backward-regexp elements
|
||||
(point-min) t))
|
||||
t)
|
||||
|
@ -1347,6 +1383,131 @@ the end of the region to place the overlay."
|
|||
(goto-char start)
|
||||
(point-marker)))))
|
||||
|
||||
(defun wesnoth-kill-block ()
|
||||
"Kill the block at point."
|
||||
(interactive)
|
||||
(save-excursion
|
||||
(let ((kill-whole-line t))
|
||||
(if (looking-at "[\t ]*\\(\\[\\+?\\(\\w\\|_\\)+\\]\\|#define\\|\
|
||||
#ifn?def\\)")
|
||||
(kill-region (point)
|
||||
(save-excursion
|
||||
(wesnoth-jump-to-matching)
|
||||
(forward-line 1)
|
||||
(point)))
|
||||
(kill-line))
|
||||
(wesnoth-indent))))
|
||||
|
||||
(defun wesnoth-mark-block ()
|
||||
"Mark the block at point."
|
||||
(interactive)
|
||||
(when (looking-at "[\t ]*\\(\\[\\+?\\(\\w\\|_\\)+\\]\\|#define\\|\
|
||||
#ifn?def\\)")
|
||||
(push-mark (save-excursion
|
||||
(wesnoth-jump-to-matching)
|
||||
(end-of-line)
|
||||
(point)))))
|
||||
|
||||
(defun wesnoth-down-list (&optional arg)
|
||||
"Move forward down ARG levels of elements.
|
||||
If ARG is not specified, move forward down one level."
|
||||
(interactive "p")
|
||||
(unless arg
|
||||
(setq arg 1))
|
||||
(when (looking-at "\\(\\[\\+?\\(\\w\\|_\\)+\\]\\|#define\\|\
|
||||
#ifn?def\\|\\(\\w\\|_\\)+=\\)")
|
||||
(forward-char 1))
|
||||
(let ((target nil))
|
||||
(save-excursion
|
||||
(when (looking-at "\\(\\w\\|_\\)+=")
|
||||
(if (and (search-forward-regexp (wesnoth-element) (point-max) t)
|
||||
(progn (beginning-of-line)
|
||||
(looking-at (wesnoth-element-opening t))))
|
||||
(setq target (point))
|
||||
(message "%s" "Innermost level"))))
|
||||
(when target (goto-char target)))
|
||||
(while (> arg 0)
|
||||
(when (> (save-excursion (wesnoth-jump-to-matching) (point)) (point))
|
||||
(search-forward-regexp
|
||||
"\\(\\[\\+?\\(\\w\\|_\\)+\\]\\|#define\\|#ifn?def\\|\\(\\w\\|_\\)+=\\)"
|
||||
(save-excursion
|
||||
(wesnoth-jump-to-matching)
|
||||
(point))
|
||||
t))
|
||||
(setq arg (1- arg)))
|
||||
(back-to-indentation))
|
||||
|
||||
(defun wesnoth-backward-up-list (&optional arg)
|
||||
"Move backward up ARG levels of elements.
|
||||
If ARG is not specified, move backward up one level."
|
||||
(interactive "p")
|
||||
(unless arg
|
||||
(setq arg 1))
|
||||
(let ((parent nil))
|
||||
(while (> arg 0)
|
||||
(setq parent (cdr (wesnoth-parent-tag)))
|
||||
(if (numberp parent)
|
||||
(progn
|
||||
(goto-char parent)
|
||||
(setq arg (1- arg)))
|
||||
(message "%s" "Outermost level")
|
||||
(setq arg 0))
|
||||
(when (numberp parent)
|
||||
(back-to-indentation)))))
|
||||
|
||||
(defun wesnoth-forward-list (&optional arg)
|
||||
"Move to forward ARG elements at the current depth.
|
||||
If ARG is not specifed, move forward one element."
|
||||
(interactive "p")
|
||||
(unless arg
|
||||
(setq arg 1))
|
||||
(when (save-excursion (beginning-of-line)
|
||||
(looking-at (wesnoth-element-opening)))
|
||||
(wesnoth-jump-to-matching)
|
||||
(setq arg (1- arg)))
|
||||
(let ((revert-target (point)))
|
||||
(while (> arg 0)
|
||||
(beginning-of-line)
|
||||
(unless (looking-at (wesnoth-element-closing))
|
||||
(wesnoth-jump-to-matching))
|
||||
(end-of-line)
|
||||
(if (and (search-forward-regexp (wesnoth-element) (point-max) t)
|
||||
(save-excursion (beginning-of-line)
|
||||
(looking-at (wesnoth-element-opening))))
|
||||
(setq revert-target (point))
|
||||
(goto-char revert-target)
|
||||
(message "%s" "End of block"))
|
||||
(setq arg (1- arg))))
|
||||
(when (save-excursion (beginning-of-line)
|
||||
(looking-at (wesnoth-element-opening)))
|
||||
(wesnoth-jump-to-matching))
|
||||
(end-of-line))
|
||||
|
||||
(defun wesnoth-backward-list (&optional arg)
|
||||
"Move to backward ARG elements at the current depth.
|
||||
If ARG is not specifed, move backward one element."
|
||||
(interactive "p")
|
||||
(unless arg
|
||||
(setq arg 1))
|
||||
(when (save-excursion (beginning-of-line)
|
||||
(looking-at (wesnoth-element-closing)))
|
||||
(wesnoth-jump-to-matching)
|
||||
(setq arg (1- arg)))
|
||||
(let ((revert-target (point)))
|
||||
(while (> arg 0)
|
||||
(beginning-of-line)
|
||||
(unless (looking-at (wesnoth-element-opening))
|
||||
(wesnoth-jump-to-matching))
|
||||
(if (and (search-backward-regexp (wesnoth-element) (point-min) t)
|
||||
(save-excursion (beginning-of-line)
|
||||
(looking-at (wesnoth-element-closing))))
|
||||
(setq revert-target (point))
|
||||
(goto-char revert-target)
|
||||
(message "%s" "Beginning of block"))
|
||||
(setq arg (1- arg))))
|
||||
(when (looking-at (wesnoth-element-closing))
|
||||
(wesnoth-jump-to-matching)))
|
||||
|
||||
(defun wesnoth-check-wml ()
|
||||
"Perform context-sensitive analysis of WML-code."
|
||||
(interactive)
|
||||
|
@ -1397,7 +1558,8 @@ the end of the region to place the overlay."
|
|||
(save-match-data
|
||||
(when
|
||||
(looking-at
|
||||
"{\\(FOREACH\\|NEXT\\).*[\t ]+\\(\\(?:\\w\\|_\\)+\\)}")
|
||||
"{\\(FOREACH\\|NEXT\\).*[\t ]+\
|
||||
\\(\\(?:\\w\\|_\\)+\\)}")
|
||||
(if (string= (match-string-no-properties 1) "FOREACH")
|
||||
(setq foreach
|
||||
(cons (match-string-no-properties 2) foreach))
|
||||
|
|
|
@ -1,20 +1,18 @@
|
|||
\input texinfo
|
||||
@c %**start of header
|
||||
@setfilename wesnoth-mode.info
|
||||
@settitle Wesnoth Mode Manual
|
||||
|
||||
@set VERSION 1.3.4
|
||||
@set DATE January 2009
|
||||
@set VERSION 1.3.5
|
||||
@set WMLVERSION 1.5.11
|
||||
@set DATE February 2009
|
||||
|
||||
@dircategory Emacs
|
||||
@direntry
|
||||
* Wesnoth Mode: (wesnoth-mode). Major-mode for editing WML
|
||||
@end direntry
|
||||
|
||||
@c Contact information
|
||||
@set MAINTAINERSITE @uref{http://www.wesnoth.org/forum/viewtopic.php?t=13798}
|
||||
@set AUTHOR Chris Mann
|
||||
@c %**end of header
|
||||
@finalout
|
||||
|
||||
@copying
|
||||
|
@ -42,15 +40,15 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
@titlepage
|
||||
@title Wesnoth Mode Manual
|
||||
@subtitle Version @value{VERSION}
|
||||
@author by Chris Mann
|
||||
|
||||
@author by @value{AUTHOR}
|
||||
@page
|
||||
|
||||
@vskip 0pt plus 1fill
|
||||
@vskip 0pt plus 1filll
|
||||
@insertcopying
|
||||
@end titlepage
|
||||
|
||||
@contents
|
||||
@summarycontents
|
||||
|
||||
@ifnottex
|
||||
@node Top, Introduction, (dir), (dir)
|
||||
@top Wesnoth Mode Manual
|
||||
|
@ -62,7 +60,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
* Introduction:: Getting started
|
||||
* Basic Usage:: Moving around within WML
|
||||
* Inserting Elements:: Insertion and completion of elements
|
||||
* Checking WML:: Checking WML for common problems
|
||||
* Validating WML:: Validating WML for common problems
|
||||
* Customisation:: Available customisation options
|
||||
|
||||
@detailmenu
|
||||
|
@ -77,21 +75,22 @@ Basic Usage
|
|||
|
||||
* Indentation:: Indentation usage and styles
|
||||
* Navigation:: Common WML navigation
|
||||
* Editing Extras:: Specialised editing commands
|
||||
|
||||
Inserting Elements
|
||||
|
||||
* Standard Completion:: Completion commands and functionality
|
||||
* Tab-Completion:: Element tab-completion
|
||||
* Tab Completion:: Element tab completion
|
||||
* Wrapping Elements:: Wrapping elements around sets of tags
|
||||
* Missing Elements:: Finding and inserting missing elements
|
||||
|
||||
Checking WML
|
||||
Validating WML
|
||||
|
||||
* Usage and Capabilities:: What to expect when checking WML
|
||||
* Usage and Capabilities:: What to expect when validating WML
|
||||
|
||||
Customisation
|
||||
|
||||
* Indentation:: Customising WML indentation
|
||||
* Modifying Indentation:: Customising WML indentation
|
||||
* Wesnoth Update:: Using and configuring Wesnoth Update
|
||||
* Macro Definitions:: Making project-local macros known
|
||||
|
||||
|
@ -119,7 +118,7 @@ units, savefiles, and the user interface layout."
|
|||
Wesnoth Mode is supported under GNU Emacs 21 onwards and (with some
|
||||
minor limitations) XEmacs 21. Wesnoth Mode adds support for syntax
|
||||
highlighting, automatic indentation, context-sensitive completion,
|
||||
checking and much more when editing WML.
|
||||
validation and more when editing WML.
|
||||
|
||||
This documentation attempts to provide a comprehensive guide to
|
||||
functionality available within Wesnoth Mode @value{VERSION}, and assumes
|
||||
|
@ -145,42 +144,51 @@ extension.
|
|||
Wesnoth Mode can be activated as the current major-mode for a buffer via
|
||||
@kbd{M-x wesnoth-mode}.
|
||||
|
||||
The latest version of Wesnoth Mode along with release notes can be found
|
||||
The latest release of Wesnoth Mode along with release notes can be found
|
||||
at @uref{http://www.wesnoth.org/forum/viewtopic.php?t=13798}.
|
||||
|
||||
Alternatively, the development version is available using git. To
|
||||
checkout the latest changes, the following command can be used:
|
||||
@example
|
||||
@code{git clone git://repo.or.cz/wesnoth-mode.git}.
|
||||
@end example
|
||||
|
||||
@node Basic Usage, Inserting Elements, Introduction, Top
|
||||
@chapter Basic Usage
|
||||
|
||||
@menu
|
||||
* Indentation:: Common WML navigation
|
||||
* Navigation:: Moving backward and forward across elements
|
||||
* Editing Extras:: Specialised editing commands
|
||||
@end menu
|
||||
|
||||
@node Indentation, Navigation, Basic Usage, Basic Usage
|
||||
@section Indentation
|
||||
@kindex @kbd{TAB}
|
||||
By default, Wesnoth Mode provides a style of indentation equivalent to
|
||||
that provided by the @code{wmlindent} tool included with Wesnoth.
|
||||
@kbd{TAB} can be used to indent the current line manually. Wesnoth Mode
|
||||
will, by default, indent the current line appropriately before inserting
|
||||
a newline when @kbd{RET} or @kbd{C-j} is used. (@kbd{C-j} will also
|
||||
attempt to indent the new line.)
|
||||
that provided by @code{wmlindent} tool distributed with Wesnoth.
|
||||
@kbd{TAB} can be used to automatically indent the current line to the
|
||||
correct depth. @kbd{TAB} can perform two actions depending on the
|
||||
context of point. When there is an incomplete element immediately
|
||||
preceding point, completion will be attempted, otherwise @kbd{TAB} will
|
||||
perform indentation. See @ref{Tab Completion}.
|
||||
|
||||
Wesnoth Mode will, by default, indent the current line appropriately
|
||||
before inserting a newline when @kbd{RET} or @kbd{C-j} is
|
||||
used. (@kbd{C-j} will also attempt to indent the new line.)
|
||||
|
||||
See @ref{Modifying Indentation} for information on how to customise the
|
||||
behaviour of automatic indentation.
|
||||
|
||||
@kbd{TAB} performs two actions depending on the context of point. When
|
||||
there is an incomplete element immediately preceeding point, completion
|
||||
will be attempted, otherwise @kbd{TAB} will perform indentation. See
|
||||
@ref{Tab-Completion}.
|
||||
|
||||
@node Navigation, , Indentation, Basic Usage
|
||||
@node Navigation, Editing Extras, Indentation, Basic Usage
|
||||
@section Navigation
|
||||
|
||||
Built-in commands for navigation are available. This section describes
|
||||
additional or modified navigation commands specific to Wesnoth Mode.
|
||||
|
||||
Next and previous opening elements can be navigated using @kbd{C-M-e}
|
||||
and @kbd{C-M-a}, respectively. In each case, point will be positioned
|
||||
immediately before the element. When no more elements are available in
|
||||
that direction, point will not move.
|
||||
that direction, the position of point will not change.
|
||||
|
||||
Moving to the matching element in a pair or locating the parent element
|
||||
(depending on the position of point) can be performed via @kbd{C-c C-o}.
|
||||
|
@ -189,17 +197,32 @@ tag or opening preprocessor statement it will be moved to the start of
|
|||
the matching closing element. Otherwise, the jump will position point
|
||||
at the beginning of the corresponding opening element.
|
||||
|
||||
@node Inserting Elements, Checking WML, Basic Usage, Top
|
||||
Structured navigation is available with @kbd{C-M-n} and @kbd{C-M-p}
|
||||
providing the ability to move to the next and previous blocks
|
||||
(respectively) which are at the same depth as the element where the
|
||||
command was invoked. @kbd{C-M-d} will move to the child of the element
|
||||
at point and @kbd{C-M-u} moving to the corresponding parent element.
|
||||
|
||||
@node Editing Extras, , Navigation, Basic Usage
|
||||
@section Editing Extras
|
||||
|
||||
Additional commands have been added to assist editing regions of WML.
|
||||
@kbd{C-M-k} can be used to kill the element at point up to the
|
||||
corresponding closing element, including all contents. Also, when point
|
||||
is at an opening element, the mark can be placed at the end of the
|
||||
corresponding closing element using @kbd{C-M-SPC}.
|
||||
|
||||
@node Inserting Elements, Validating WML, Basic Usage, Top
|
||||
@chapter Inserting Elements
|
||||
|
||||
@menu
|
||||
* Standard Completion:: Completion commands and functionality
|
||||
* Tab-Completion:: Element tab-completion
|
||||
* Tab Completion:: Element tab completion
|
||||
* Wrapping Elements:: Wrapping elements around sets of tags
|
||||
* Missing Elements:: Finding and inserting missing elements
|
||||
@end menu
|
||||
|
||||
@node Standard Completion, Tab-Completion, Inserting Elements, Inserting Elements
|
||||
@node Standard Completion, Tab Completion, Inserting Elements, Inserting Elements
|
||||
@section Standard Completion
|
||||
|
||||
Tags can be inserted via @kbd{C-c C-t} and alternatively @kbd{M-TAB}
|
||||
|
@ -214,7 +237,7 @@ following.
|
|||
|
||||
Both tag and attribute completion is context-sensitive. If an element
|
||||
is available in WML and not listed for completion, it can be added to
|
||||
the `addition file'. See @ref{Wesnoth Update} for more information.
|
||||
the `addition file'. See @ref{Addition File} for more information.
|
||||
|
||||
Macro insertion can be performed via @kbd{C-c C-m}. Any arguments known
|
||||
to be required for the macro will be prompted and inserted in order.
|
||||
|
@ -229,8 +252,8 @@ Closing elements for preprocessor statements will be automatically
|
|||
inserted where possible, with point positioned between. Otherwise,
|
||||
point will be placed immediately after the inserted text.
|
||||
|
||||
@node Tab-Completion, Wrapping Elements, Standard Completion, Inserting Elements
|
||||
@section Tab-Completion
|
||||
@node Tab Completion, Wrapping Elements, Standard Completion, Inserting Elements
|
||||
@section Tab Completion
|
||||
|
||||
Completion can also be performed immediately within the buffer via
|
||||
@kbd{TAB} on a partial element. For example:
|
||||
|
@ -248,7 +271,7 @@ When there is more than one possible completion, a minibuffer prompt
|
|||
will be provided, with the partial element entered. @kbd{TAB} can be
|
||||
used here to perform completion. If multiple matches are available,
|
||||
completion will be performed up to the smallest common substring with
|
||||
further completion available via the minubuffer prompt. When no matches
|
||||
further completion available via the minibuffer prompt. When no matches
|
||||
are found for the partial element, completion will not be prompted.
|
||||
|
||||
When completing opening preprocessor statements and tags, Wesnoth Mode
|
||||
|
@ -257,13 +280,13 @@ already available, acting in much the same way as if the element was
|
|||
added via the minibuffer prompt. However, if an matching closing
|
||||
element is available, only the element at point will be completed.
|
||||
|
||||
A numeric argument can be provided when performing tab-completion of
|
||||
A numeric argument can be provided when performing tab completion of
|
||||
opening elements to wrap around the next @i{n} blocks. For
|
||||
example, to wrap the completed opening and closing pair around the next
|
||||
three blocks, @kbd{C-u 3 TAB} can be used. See @ref{Wrapping Elements}
|
||||
for more information.
|
||||
|
||||
@node Wrapping Elements, Missing Elements, Tab-Completion, Inserting Elements
|
||||
@node Wrapping Elements, Missing Elements, Tab Completion, Inserting Elements
|
||||
@section Wrapping Elements
|
||||
When inserting tags and some preprocessor statements, either via their
|
||||
respective insertion command or via @kbd{TAB}, an optional numeric
|
||||
|
@ -297,29 +320,28 @@ current buffer at point. If all elements appear to be matched or if
|
|||
there is an excess of closing tags, a notification will be displayed and
|
||||
no element will be inserted.
|
||||
|
||||
@node Checking WML, Customisation, Inserting Elements, Top
|
||||
@chapter Checking WML
|
||||
@node Validating WML, Customisation, Inserting Elements, Top
|
||||
@chapter Validating WML
|
||||
|
||||
@menu
|
||||
* Usage and Capabilities:: What to expect when checking WML
|
||||
* Usage and Capabilities:: What to expect when validating WML
|
||||
@end menu
|
||||
|
||||
@node Usage and Capabilities, , Checking WML, Checking WML
|
||||
@node Usage and Capabilities, , Validating WML, Validating WML
|
||||
@section Usage and Capabilities
|
||||
|
||||
Checking WML in the current buffer can be performed using @kbd{C-c C-c},
|
||||
Validating WML in the current buffer can be performed using @kbd{C-c C-c},
|
||||
with a summary of all warnings found reported in a separate buffer.
|
||||
Point can be jumped to the next and previous warning using @kbd{C-c C-f}
|
||||
(or @kbd{C-x `}) and @kbd{C-c C-b}, respectively. For visibility,
|
||||
warnings will be underlined in red by default. @i{Note: Warning
|
||||
underlines may not be available in XEmacs.}
|
||||
|
||||
The WML checking built-in to Wesnoth Mode is not intended to be an
|
||||
The WML validation built-in to Wesnoth Mode is not intended to be an
|
||||
alternative to tools such as `wmllint', but may often be a convenient
|
||||
substitute while editing WML.
|
||||
|
||||
The following conditions can be detected by WML checking in Wesnoth
|
||||
Mode:
|
||||
The following conditions can be tested in Wesnoth Mode:
|
||||
@itemize
|
||||
@item Correct nesting of tags and preprocessor statements
|
||||
@item Known macro definitions @footnote{see @ref{Macro Definitions}}
|
||||
|
@ -329,10 +351,10 @@ Mode:
|
|||
@item Corresponding FOREACH..NEXT pairs
|
||||
@end itemize
|
||||
|
||||
WML checking is specific to the version of WML known by Wesnoth Mode.
|
||||
WML validation is specific to the version of WML known by Wesnoth Mode.
|
||||
See @ref{Wesnoth Update} for more information.
|
||||
|
||||
@node Customisation, , Checking WML, Top
|
||||
@node Customisation, , Validating WML, Top
|
||||
@chapter Customisation
|
||||
|
||||
@menu
|
||||
|
@ -388,21 +410,23 @@ By default, Wesnoth Mode will use spaces for indentation. Tabs can instead be u
|
|||
@end example
|
||||
|
||||
@code{wesnoth-warning-face} is the face used to display the overlay for
|
||||
warnings detected when checking WML (See @ref{Checking WML}). By
|
||||
warnings detected when Validating WML (See @ref{Validating WML}). By
|
||||
default this is a red underline. @i{Note: use of this face may not be supported
|
||||
under XEmacs.}
|
||||
|
||||
@node Wesnoth Update, Macro Definitions, Modifying Indentation, Customisation
|
||||
@node Wesnoth Update, Addition File, Modifying Indentation, Customisation
|
||||
@section Wesnoth Update
|
||||
|
||||
Wesnoth Update controls the known WML data for Wesnoth Mode. To update
|
||||
this information, two variables need to be set appropriately:
|
||||
@code{wesnoth-root-directory} and @code{wesnoth-update-output-directory}.
|
||||
Wesnoth Update is an extension to Wesnoth Mode which retrieves
|
||||
information regarding valid WML structure using WML included with
|
||||
Wesnoth. To update WML data known to Wesnoth Mode, two variables need
|
||||
to be set appropriately: @code{wesnoth-root-directory} and
|
||||
@code{wesnoth-update-output-directory}.
|
||||
|
||||
@code{wesnoth-root-directory} should be the path to the root directory
|
||||
of a Wesnoth installation or Wesnoth source code. Wesnoth Update will
|
||||
search recursively in this directory for WML, using the information
|
||||
found to provide context-sensitive completion and WML checking.
|
||||
found to provide context-sensitive completion and WML validation.
|
||||
|
||||
@code{wesnoth-update-output-directory} specifies the path to store the
|
||||
WML data found. This path should be within the @code{load-path}, and
|
||||
|
@ -416,17 +440,23 @@ For example:
|
|||
|
||||
Once set, @kbd{M-x wesnoth-update} will generate and load a new cache of
|
||||
WML data ready for use for the current and future sessions. @i{Note:
|
||||
@code{wesnoth-update} may take some time to run.}
|
||||
'wesnoth-update' may take some time to run.}
|
||||
|
||||
Wesnoth Mode @value{VERSION} uses WML data retrieved from Wesnoth
|
||||
@value{WMLVERSION}, by default.
|
||||
|
||||
@node Addition File, Macro Definitions, Wesnoth Update, Customisation
|
||||
@section Addition File
|
||||
|
||||
@code{wesnoth-addition-file} specifies the `addition file' to use. An
|
||||
addition file is an outline of a valid WML file which is processed for
|
||||
additional element data which may not have been detected when running
|
||||
@code{wesnoth-update}. This should be set as the path to a suitable
|
||||
addition file. A sample addition file is included with Wesnoth Mode.
|
||||
addition file is an outline of a valid WML structure which is processed
|
||||
to provide more comprehensive completion and validation by providing
|
||||
access to elements which may not have been available when running
|
||||
@code{wesnoth-update}.
|
||||
|
||||
The addition data is read from the file and updated any time tag
|
||||
information is required, therefore no action needs to be taken to adjust
|
||||
tag data other than saving the addition file when modified.
|
||||
The value of @code{wesnoth-addition-file} should be set as the path to a
|
||||
suitable addition file. A sample addition file is included with Wesnoth
|
||||
Mode.
|
||||
|
||||
For example, the following could be used to specify an addition file:
|
||||
@example
|
||||
|
@ -434,6 +464,11 @@ For example, the following could be used to specify an addition file:
|
|||
"~/.emacs.d/wesnoth-mode/wesnoth-wml-additions.cfg")
|
||||
@end example
|
||||
|
||||
The addition file is read and information regarding WML structure
|
||||
updated any time WML information is required. Therefore, no further
|
||||
action is required to use the updated WML data once any changes to the
|
||||
addition file are saved to disk.
|
||||
|
||||
@node Macro Definitions, , Wesnoth Update, Customisation
|
||||
@section Macro Definitions
|
||||
|
||||
|
|
|
@ -25,7 +25,8 @@
|
|||
;; correctly generate WML data:
|
||||
;; (setq wesnoth-root-directory "/path/to/wesnoth/"
|
||||
;; wesnoth-update-output-directory "/path/to/wesnoth-mode/"
|
||||
;; wesnoth-addition-file "/path/to/wesnoth-mode/wesnoth-wml-additions.cfg")
|
||||
;; wesnoth-addition-file
|
||||
;; "/path/to/wesnoth-mode/wesnoth-wml-additions.cfg")
|
||||
;; Specifying the appropriate path in each case.
|
||||
|
||||
;; Although WML data is provided along with wesnoth-mode, you can generate
|
||||
|
@ -206,14 +207,16 @@ DIR-OR-FILE can be a file, a directory, or a list of files."
|
|||
(point-min) t))
|
||||
(string-match "#define " (match-string 1))
|
||||
(looking-at "^[\t ]*\\[\\+?\\(\\(\\w\\|_\\)+\\)\\]"))
|
||||
(wesnoth-append-tag-information (match-string-no-properties 1) nil nil)
|
||||
(wesnoth-append-tag-information (match-string-no-properties 1)
|
||||
nil nil)
|
||||
(setq unmatched-tag-list (cons (match-string-no-properties 1)
|
||||
unmatched-tag-list)))
|
||||
((looking-at "^[\t ]*\\[\\+?\\(\\(\\w\\|_\\)+\\)\\]")
|
||||
(wesnoth-append-tag-information (car unmatched-tag-list)
|
||||
(match-string-no-properties 1)
|
||||
nil)
|
||||
(wesnoth-append-tag-information (match-string-no-properties 1) nil nil)
|
||||
(wesnoth-append-tag-information (match-string-no-properties 1)
|
||||
nil nil)
|
||||
(setq unmatched-tag-list (cons (match-string-no-properties 1)
|
||||
unmatched-tag-list)))
|
||||
((looking-at "^[\t ]*\\(\\(\\w\\|_\\)+\\)=")
|
||||
|
@ -230,8 +233,9 @@ DIR-OR-FILE can be a file, a directory, or a list of files."
|
|||
SUBTAG and ATTRIBUTE are a children of TAG to be added."
|
||||
(let ((match (assoc tag wesnoth-tmp-tag-data)))
|
||||
(if (not match)
|
||||
(add-to-list 'wesnoth-tmp-tag-data (list tag (and subtag (list subtag))
|
||||
(and attribute (list attribute))))
|
||||
(add-to-list 'wesnoth-tmp-tag-data
|
||||
(list tag (and subtag (list subtag))
|
||||
(and attribute (list attribute))))
|
||||
(if subtag
|
||||
(let ((tmp (nth 1 match)))
|
||||
(when (not (member subtag tmp))
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
[/multiplayer]
|
||||
|
||||
[era]
|
||||
require_era=
|
||||
[multiplayer_side]
|
||||
|
||||
[/multiplayer_side]
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Add table
Reference in a new issue