Emacs major mode for Dialog

I am experimenting with Dialog at the moment and one of the small things that really annoy me is not being able to justify paragraphs in the source code automatically. The inform-mode for Emacs does this really well, and I want the same for Dialog.

Thus I have started working on an Emacs major mode for editing Dialog code. It’s not yet ready for public consumption, but I’m writing this to ask N things:

  • Is this something that would interest you?
  • Is this something that would interest you enough to contribute code to it?
  • Is this something that already exists and I’m reinventing the wheel?

I get that the intersection between Emacs users and IF authors that use Dialog is probably pretty small, but I’m still curious if it’s just me or at least one other person.

5 Likes

I’ve found Dyalog surprisingly usable without a dedicated mode, but I’d use it.

Edit: and contribute if I happened to implement something, although I’m focused on other things right now.

I don’t currently use Emacs, but my current source editor isn’t great for Dialog (I can’t see an outline of object and rule definitions to jump to for example), so if it’s good enough I could be convinced to switch!

I think Emacs already does that with outline-minor-mode. Setting outline-regexp to a good default would be low hanging fruit for a dialog-mode. I’ve just got it set to ”#”.

3 Likes

I did start one a couple of years ago but I haven’t looked at it much in the last year. It does include a partial parser and could re-indent the standard library without modifying the indentation, although I did find at least one place where the use of whitespace by convention was significant.

The git repository was never made public but I’ll attach a copy of what it looks like in its current state. I was originally planning to keep adding more tests and then go back and try to simplify/cleanup the parser code.

I think it is actually usable in its current state but I wouldn’t want to release it or endorse its use as it stands right now.

dialog-mode.zip (8.7 KB)

3 Likes

I decided to try and finish it and so it is now available from here:

There isn’t a separate manual at the moment so the README file (which is the same as the package commentary) is where the (very terse) instructions are.

The most interesting part is the integration with the Dialog debugger, where the debugger runs inside Emacs and you can send it commands. This effectively gives you hot-reload while editing by sending @replay to the debugger after saving changes to the source files. If you are using Windows there are significant restrictions for debug integration because the debugger is built as a graphical application.

I would appreciate it if anyone interested would try it out to rule out any obvious issues. It currently isn’t available on a package repository but you can either install it manually or by using package-vc-install and giving it the Git repository URL.

4 Likes

Ooh I will definitely try it. What a Christmas gift to the community! I’ll also see if I can contribute my machinations into it instead of duplicating the effort. Thanks for making it available!

Do you know how best to collaborate on a project like this on Sourcehut? I have for example this commit which fixes a paragraph-filling bug (complete with test case and everything!) but I’m not sure how to propose it for inclusion in your repository: https://git.sr.ht/~kqr/dialog-mode/commit/0bd6e44e0af3e91df7e690489bf8977fd786c197

I plan on also suggesting some paragraph-filling heuristics which have worked well for me, but I want to get this bugfix through first to better understand the Sourcehut collaboration model and get more acquainted with your code!

Edit: Ah, I see, email. Patch coming your way as soon as I have time to format it.

RE: your patch. There are a lot of checks for syntax that isn’t technically valid to avoid false matches for other functionality, e.g. Flymake would already indicate that this is a problem but I’m not sure I would want to break other functionality just because the syntax isn’t valid:

(intro)

		Hurrying through the rainswept November night, you're glad to
		see the bright lights of the Opera House. It's surprising that
		there aren't more people about but, hey, "what do you expect in
(problem)	a cheap demo game...?"

In this case I think I would rather just restrict the fill to the current line when inside a string and treat it like any other non-comment line.

Edit: I think I will modify the syntax table to remove " as a string delimiter. This should allow all the string checks to be removed or renamed.

1 Like

To be clear, in the test case added, the current fill-paragraph behaviour is bad so some fix is necessary, although it might not be my suggestion.

That is probably a better solution than mine. Thanks!

I use Emacs exclusively for editing Dialog, and would love a major mode.

Just to note, I am still actively working on this.

The weak point at the moment is the paragraph motion/filling, but I am actively working on that now (mostly done, just need to add tests to convince myself it works), and then I plan on making the mode (with manual) available on a package repository.

1 Like

It is now available on MELPA if anyone would like to try it out. When you install it you should also get the manual.

I think the definition of what a paragraph is should work for most people but you can customise it if you want something different (see dialog-paragraph-delimiter). There are key-bindings for moving by paragraph if you want to visually check where the boundaries are.

1 Like