Emacs WML-mode

The place to post your WML questions and answers.

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.
WildPenguin
Posts: 161
Joined: September 6th, 2005, 10:41 pm
Location: Australia

Re: Emacs WML-mode

Post by WildPenguin »

fabi wrote:When tab-completing a macro, can the arguments' names be inserted as well?
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
Inactive Developer
Posts: 1260
Joined: March 21st, 2004, 2:42 pm
Location: Germany

Re: Emacs WML-mode

Post by fabi »

WildPenguin wrote:
fabi wrote:When tab-completing a macro, can the arguments' names be inserted as well?
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?
That sounds fine. :-)
fabi
Inactive Developer
Posts: 1260
Joined: March 21st, 2004, 2:42 pm
Location: Germany

Re: Emacs WML-mode

Post by fabi »

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
WildPenguin
Posts: 161
Joined: September 6th, 2005, 10:41 pm
Location: Australia

Re: Emacs WML-mode

Post by WildPenguin »

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.
fabi
Inactive Developer
Posts: 1260
Joined: March 21st, 2004, 2:42 pm
Location: Germany

Re: Emacs WML-mode

Post by fabi »

Commited
Anonymissimus
Inactive Developer
Posts: 2461
Joined: August 15th, 2008, 8:46 pm
Location: Germany

Re: Emacs WML-mode

Post by Anonymissimus »

thank you for this tool WildPenguin, it eases life a lot! i'm even willing to shoulder dealing with emacs for it :lol2:
(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 startersPlan Your Advancements: mp mod
The Earth's Gut: sp campaignSettlers of Wesnoth: mp scenarioWesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
uzytkownik
Posts: 126
Joined: April 19th, 2008, 7:12 pm
Contact:

Re: Emacs WML-mode

Post by uzytkownik »

Practical common lisp - it is about clisp not elisp but I guess that combined with elisp manuals it will be sufficient.
WildPenguin
Posts: 161
Joined: September 6th, 2005, 10:41 pm
Location: Australia

Re: Emacs WML-mode

Post by WildPenguin »

Anonymissimus wrote:inside [set_variable][/set_variable], Check WML doesn't know the modulo attribute
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):

Code: Select all

[set_variable]
        modulo=
[set_variable]
Then set up Wesnoth Update as described in the manual and run 'M-x wesnoth-update'. I believe this feature has not yet been widely tested. Please let me know if you have any problems with it or with the documentation. The modulo attribute has been added for future versions of Wesnoth Mode.

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
to the Wesnoth addition file (and run 'M-x wesnoth-update') and they will always be available.

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.
Anonymissimus
Inactive Developer
Posts: 2461
Joined: August 15th, 2008, 8:46 pm
Location: Germany

Re: Emacs WML-mode

Post by Anonymissimus »

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 ?
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml startersPlan Your Advancements: mp mod
The Earth's Gut: sp campaignSettlers of Wesnoth: mp scenarioWesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
WildPenguin
Posts: 161
Joined: September 6th, 2005, 10:41 pm
Location: Australia

Re: Emacs WML-mode

Post by WildPenguin »

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".
Thanks. These have been fixed.
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.
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):

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)))
Does this work as expected?

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.
fabi
Inactive Developer
Posts: 1260
Joined: March 21st, 2004, 2:42 pm
Location: Germany

Re: Emacs WML-mode

Post by fabi »

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
Anonymissimus
Inactive Developer
Posts: 2461
Joined: August 15th, 2008, 8:46 pm
Location: Germany

Re: Emacs WML-mode

Post by Anonymissimus »

WildPenguin wrote:

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)))
Does this work as expected?
It does, thank you.
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.
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.
Not that important for me, unlike the tab issue. Tabs are easier to work with on coding and can be converted to spaces anyway.

/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 startersPlan Your Advancements: mp mod
The Earth's Gut: sp campaignSettlers of Wesnoth: mp scenarioWesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
WildPenguin
Posts: 161
Joined: September 6th, 2005, 10:41 pm
Location: Australia

Re: Emacs WML-mode

Post by WildPenguin »

@fabi: Yuck. This is fixed. Thanks.
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 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.

I will update the version available now to provide fixes for these.
WildPenguin
Posts: 161
Joined: September 6th, 2005, 10:41 pm
Location: Australia

Re: Emacs WML-mode

Post by WildPenguin »

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.
Anonymissimus
Inactive Developer
Posts: 2461
Joined: August 15th, 2008, 8:46 pm
Location: Germany

Re: Emacs WML-mode

Post by Anonymissimus »

#ifdef etc is indented like a tag but doesn't cause indentation itsself

Code: Select all

	[event]
		#ifdef HARD
		name=turn 2
		#else
		name=turn 3
		#endif
	[/event]
should be

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 startersPlan Your Advancements: mp mod
The Earth's Gut: sp campaignSettlers of Wesnoth: mp scenarioWesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
Post Reply