Emacs WML-mode
Moderator: Forum Moderators
Forum rules
- Please use [code] BBCode tags in your posts for embedding WML snippets.
- To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
-
- Posts: 161
- Joined: September 6th, 2005, 10:41 pm
- Location: Australia
Re: Emacs WML-mode
This should be fairly easy to add. Perhaps a prompt for each argument expected for the macro (terminatable by specifying no argument)? Or did you have something else in mind?fabi wrote:When tab-completing a macro, can the arguments' names be inserted as well?
Re: Emacs WML-mode
That sounds fine.WildPenguin wrote:This should be fairly easy to add. Perhaps a prompt for each argument expected for the macro (terminatable by specifying no argument)? Or did you have something else in mind?fabi wrote:When tab-completing a macro, can the arguments' names be inserted as well?
Re: Emacs WML-mode
WildPenguin,
I believe to have discovered a small indentation issue with the FOREACH macro.
Between a line with {FOREACH ARRAY VARIABLE} and {NEXT VARIABLE} the lines should indent one level more.
IF the VARIABLE names don't match each other it's a mistake or you have a nested FOREACH.
Greetings, Fabi
I believe to have discovered a small indentation issue with the FOREACH macro.
Between a line with {FOREACH ARRAY VARIABLE} and {NEXT VARIABLE} the lines should indent one level more.
IF the VARIABLE names don't match each other it's a mistake or you have a nested FOREACH.
Greetings, Fabi
-
- Posts: 161
- Joined: September 6th, 2005, 10:41 pm
- Location: Australia
Re: Emacs WML-mode
Wesnoth Mode 1.3.3 is now available.
Changes include:
* Warnings are also underlined by default and can be navigated using C-c C-f (or C-x `) and C-c C-b (to navigate to the next and previous warnings, respectively).
* FOREACH blocks are now indented correctly and can be checked using C-c C-c.
* Any macro arguments are now prompted when completing or using C-c C-m.
* Improved completion behaviour.
* Improved performance and behaviour when inserting missing elements (via completion and C-c C-/).
* The version of WML used has been updated to 1.5.6.
Many bugs and inconsistencies have also been corrected.
Changes include:
* Warnings are also underlined by default and can be navigated using C-c C-f (or C-x `) and C-c C-b (to navigate to the next and previous warnings, respectively).
* FOREACH blocks are now indented correctly and can be checked using C-c C-c.
* Any macro arguments are now prompted when completing or using C-c C-m.
* Improved completion behaviour.
* Improved performance and behaviour when inserting missing elements (via completion and C-c C-/).
* The version of WML used has been updated to 1.5.6.
Many bugs and inconsistencies have also been corrected.
Re: Emacs WML-mode
Commited
-
- Inactive Developer
- Posts: 2461
- Joined: August 15th, 2008, 8:46 pm
- Location: Germany
Re: Emacs WML-mode
thank you for this tool WildPenguin, it eases life a lot! i'm even willing to shoulder dealing with emacs for it
(first success was to automatically enable line numbers...)
inside [set_variable][/set_variable], Check WML doesn't know the modulo attribute, but in wesnoth it works fine
this is bfw 1.4.2 and (probably) wesnoth mode 1.3.2, but in the reference wml there isn't any hint that this attribute is/will be removed in the development version...
can you give me a link to a good lisp tutorial (or something similiar to the reference wml) ? that's the programming language that .emacs and your wml mode use, isn't it ? currently i'm trying to find out how to autoload files so that custom macros are automatically known to wml mode, or is there a better way to do this ?
(first success was to automatically enable line numbers...)
inside [set_variable][/set_variable], Check WML doesn't know the modulo attribute, but in wesnoth it works fine
this is bfw 1.4.2 and (probably) wesnoth mode 1.3.2, but in the reference wml there isn't any hint that this attribute is/will be removed in the development version...
can you give me a link to a good lisp tutorial (or something similiar to the reference wml) ? that's the programming language that .emacs and your wml mode use, isn't it ? currently i'm trying to find out how to autoload files so that custom macros are automatically known to wml mode, or is there a better way to do this ?
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml starters • Plan Your Advancements: mp mod
The Earth's Gut: sp campaign • Settlers of Wesnoth: mp scenario • Wesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
A Simple Campaign: campaign draft for wml starters • Plan Your Advancements: mp mod
The Earth's Gut: sp campaign • Settlers of Wesnoth: mp scenario • Wesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
-
- Posts: 126
- Joined: April 19th, 2008, 7:12 pm
- Contact:
Re: Emacs WML-mode
Practical common lisp - it is about clisp not elisp but I guess that combined with elisp manuals it will be sufficient.
-
- Posts: 161
- Joined: September 6th, 2005, 10:41 pm
- Location: Australia
Re: Emacs WML-mode
Due to the way the known elements are discovered, this may happen from time-to-time for less-frequently used attributes; any missing elements can be added through the 'addition file'. The WML in Wesnoth Mode follows the development branch, but this can be changed to use WML available in 1.4.x. See Wesnoth Update in the manual. To add the modulo attribute, add something like this to 'wesnoth-wml-additions.cfg' (included with Wesnoth Mode):Anonymissimus wrote:inside [set_variable][/set_variable], Check WML doesn't know the modulo attribute
Code: Select all
[set_variable]
modulo=
[set_variable]
Custom macros are scanned and made known when opening a WML file and any macro definition can be updated using 'C-c C-u' in the buffer it was defined. If you have a set of macros you use frequently though, you can add:
Code: Select all
#define CUSTOM_MACRO ARG1 ARG2
#enddef
Wesnoth Mode is indeed written entirely in Elisp. For learning Elisp I recommend the Emacs Lisp Manual. Although I find the manual is a handy reference, I will usually use the in-built documentation available through 'C-h f', 'C-h v', etc. for specific details. The first few chapters of Practical Common Lisp are also good as an introduction to Lisp concepts that may be worth reading.
-
- Inactive Developer
- Posts: 2461
- Joined: August 15th, 2008, 8:46 pm
- Location: Germany
Re: Emacs WML-mode
a few things
-Inside the code block in the update section in the online manual the ")" at the end is missing. Resetting the wml data to a previous wesnoth version seems to have worked fine.
-The command description for "wesnoth-newline" is erroneously that one from "wesnoth-newline-and-indent". Emacs showed some strange behaviour while I was trying to bind the RET key to newline-and-indent like in other editors, instead of newline; maybe there's more wrong. Why are the options for inserting tabs instead of spaces when indenting and the one for indenting #ifdef #enddef like a tag no longer available ?
-Inside the code block in the update section in the online manual the ")" at the end is missing. Resetting the wml data to a previous wesnoth version seems to have worked fine.
-The command description for "wesnoth-newline" is erroneously that one from "wesnoth-newline-and-indent". Emacs showed some strange behaviour while I was trying to bind the RET key to newline-and-indent like in other editors, instead of newline; maybe there's more wrong. Why are the options for inserting tabs instead of spaces when indenting and the one for indenting #ifdef #enddef like a tag no longer available ?
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml starters • Plan Your Advancements: mp mod
The Earth's Gut: sp campaign • Settlers of Wesnoth: mp scenario • Wesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
A Simple Campaign: campaign draft for wml starters • Plan Your Advancements: mp mod
The Earth's Gut: sp campaign • Settlers of Wesnoth: mp scenario • Wesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
-
- Posts: 161
- Joined: September 6th, 2005, 10:41 pm
- Location: Australia
Re: Emacs WML-mode
Thanks. These have been fixed.Anonymissimus wrote:Inside the code block in the update section in the online manual the ")" at the end is missing. Resetting the wml data to a previous wesnoth version seems to have worked fine.
-The command description for "wesnoth-newline" is erroneously that one from "wesnoth-newline-and-indent".
I tested this just now; everything seems to work as expected. I used the following (this also configures Wesnoth Mode to use tabs for indenting):Anonymissimus wrote:Emacs showed some strange behaviour while I was trying to bind the RET key to newline-and-indent like in other editors, instead of newline; maybe there's more wrong.
Code: Select all
(add-hook 'wesnoth-mode-hook
'(lambda ()
(define-key wesnoth-mode-map (kbd "C-m") 'wesnoth-newline-and-indent)
(setq indent-tabs-mode t
tab-width wesnoth-base-indent)))
Prior to 1.3, an option did exist to indent preprocessor statements similar to that of tags. It was removed to reduce complication in the code. I intend to work on the indentation in the coming weeks anyway; if you'd find it useful let me know and I'll reimplement it.
Re: Emacs WML-mode
A "#" symbol inside a string (This gives it a red colour when displayed) causes the wml mode to ignore the closing "-symbol.
You can see that in the file data/campaigns/Legend_of_Wesmere/utils/ai_controller.cfg line 341.
Greetings, Fabi
You can see that in the file data/campaigns/Legend_of_Wesmere/utils/ai_controller.cfg line 341.
Greetings, Fabi
-
- Inactive Developer
- Posts: 2461
- Joined: August 15th, 2008, 8:46 pm
- Location: Germany
Re: Emacs WML-mode
It does, thank you.WildPenguin wrote:Does this work as expected?Code: Select all
(add-hook 'wesnoth-mode-hook '(lambda () (define-key wesnoth-mode-map (kbd "C-m") 'wesnoth-newline-and-indent) (setq indent-tabs-mode t tab-width wesnoth-base-indent)))
The thing that confused me was that while binding the C-j key to newline (swapping newline and newline-and-indent I noticed that in lisp code the key C-j is represented by just a newline, unlike the other keys...at least it works this way.
Not that important for me, unlike the tab issue. Tabs are easier to work with on coding and can be converted to spaces anyway.Prior to 1.3, an option did exist to indent preprocessor statements similar to that of tags. It was removed to reduce complication in the code. I intend to work on the indentation in the coming weeks anyway; if you'd find it useful let me know and I'll reimplement it.
/edit
an issue with comments and indention:
When running "indent buffer" over a file with a commented code block (using comment-region), the commented block is indented as well and can then no longer be uncommented directly, I need to replace the leading tabs with "nothing" first. Maybe skip commented lines on this function ?
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml starters • Plan Your Advancements: mp mod
The Earth's Gut: sp campaign • Settlers of Wesnoth: mp scenario • Wesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
A Simple Campaign: campaign draft for wml starters • Plan Your Advancements: mp mod
The Earth's Gut: sp campaign • Settlers of Wesnoth: mp scenario • Wesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
-
- Posts: 161
- Joined: September 6th, 2005, 10:41 pm
- Location: Australia
Re: Emacs WML-mode
@fabi: Yuck. This is fixed. Thanks.
I will update the version available now to provide fixes for these.
I was able to reproduce and fix an error where 'uncomment-region' would fail with "Can't find the comment end" when comments were indented. This sounds like the problem you were experiencing.Anonymissimus wrote:When running "indent buffer" over a file with a commented code block (using comment-region), the commented block is indented as well and can then no longer be uncommented directly, I need to replace the leading tabs with "nothing" first. Maybe skip commented lines on this function ?
I will update the version available now to provide fixes for these.
-
- Posts: 161
- Joined: September 6th, 2005, 10:41 pm
- Location: Australia
Re: Emacs WML-mode
Wesnoth Mode 1.3.4 has been released.
In this release the addition file no longer requires 'M-x wesnoth-update' for the changes to be made available; the file is now automatically read when required.
Also:
* Fixed some errors produced when wesnoth-mode.el is byte-compiled.
* Improve detection and position of inserted closing tags in some circustances.
* Improved context detection for completion in some circumstances.
* 'wesnoth-indent-preprocessor-bol' has been re-introduced to control whether preprocessor statements are indented to the beginning of the line or as tags.
As well as many minor bug fixes.
In this release the addition file no longer requires 'M-x wesnoth-update' for the changes to be made available; the file is now automatically read when required.
Also:
* Fixed some errors produced when wesnoth-mode.el is byte-compiled.
* Improve detection and position of inserted closing tags in some circustances.
* Improved context detection for completion in some circumstances.
* 'wesnoth-indent-preprocessor-bol' has been re-introduced to control whether preprocessor statements are indented to the beginning of the line or as tags.
As well as many minor bug fixes.
-
- Inactive Developer
- Posts: 2461
- Joined: August 15th, 2008, 8:46 pm
- Location: Germany
Re: Emacs WML-mode
#ifdef etc is indented like a tag but doesn't cause indentation itsself
should be
Code: Select all
[event]
#ifdef HARD
name=turn 2
#else
name=turn 3
#endif
[/event]
Code: Select all
[event]
#ifdef HARD
name=turn 2
#else
name=turn 3
#endif
[/event]
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml starters • Plan Your Advancements: mp mod
The Earth's Gut: sp campaign • Settlers of Wesnoth: mp scenario • Wesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
A Simple Campaign: campaign draft for wml starters • Plan Your Advancements: mp mod
The Earth's Gut: sp campaign • Settlers of Wesnoth: mp scenario • Wesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign