DosScripts

Several Emacs modes have been released for editing Dos scripts (batch files).

BatMode is the default mode for editing *.bat and *.cmd files, part of core Emacs 24.4 onwards.

bat-mode

By Arni Magnusson (2014).

BatMode provides syntax highlighting, a basic template, access to help pages, imenu/outline navigation, and the ability to run scripts from within Emacs.

bat-generic-mode

By Peter Breton (1996-2013).

Was part of core Emacs 20.3 to 24.3. Made obsolete by BatMode in Emacs 24.4.

batch-mode

By Agnar Renolen and Matthew Fidler (2002-2009). Similar to BatMode, but with fewer features.

Lisp:batch-mode.el does not recognize ::comments, :.labels, -options, or --options. No commands to run script or show help for Dos commands. No code navigation support or code templates.

Using the term batch mode here can be misleading, since the GNU Emacs Manual says: “Batch mode is used for running programs written in Emacs Lisp from shell scripts, makefiles, and so on.” This is what BatchMode is about.

cmd-mode

By Tadamegu Furukawa (2001-2005). Similar to BatMode, but with fewer features.

CmdMode does not recognize ::comments, :.labels, /options, -options, or --options. Script cannot be run from Emacs with args. Code navigation misses :.labels and is not as feature-rich as imenu+outline.

dos-mode

By Arni Magnusson (2003-2013). Predecessor of BatMode.

I added indentation for DosMode via the lisp file DosIndent – Matthew Fidler

ntcmd-mode

By Daniel Colascione (2010). Emphasis on language parser.

Lisp:ntcmd.el is a new DOS script mode that uses a parser to fully understand the cmd language. Does not natively include templating and outlining: use other minor modes, like Yasnippet, for that.


General discussion

Why is DosMode “the recommended mode for editing Dos scripts”? – Lennart Borgman

Mainly because of the shortcomings of ‘batch-mode’ and CmdMode listed above, improved code navigation, better documentation, and the code conforming to Emacs Lisp major mode conventions.

The three modes are really quite similar, so it would be best to combine all desired features in one mode. If there are any features you find lacking in DosMode, please leave comments here so I can include them in the next release. Users can also add personal features with ‘dos-mode-hook’. – Arni Magnusson

While DosMode does have navigation support, the current version does it through generic emacs outline-mode, while CmdMode does it through native, integrated navigation. The problem with the native emacs outline-mode is that you don’t get syntax highlighting, for one thing, while you are in outline mode. So I prefer CmdMode just because of that. – Eli Boling


CategoryProgramming