Syntax highlighting for Mathemagix files

The mmxlight package provides syntax highlighting files for various editors. Currently, the editors Emacs, Vim, Nano, Gedit and Kate are supported. Relevant files are in the folder

mmxlight/syntax-highlighting/<editor>/

and installation instructions for each editor are given below. An example file mmxlight/syntax-highlighting/example.mmx is also provided for testing purposes.

Emacs

To edit Mathemagix code with Emacs, the mmx mode can be used. It features automatic indentation and syntax highlighting. The necessary Emacs code is available in the file

mmxlight/syntax-highlighting/emacs/mmx-mode.el

in the Mathemagix source distribution and can be installed as follows:

mkdir -p $HOME/emacs.d/
cp mmxlight/syntax-highlighting/emacs/mmx-mode.el $HOME/.emacs.d/

The following can be added in the file $HOME/.emacs:

(setq load-path 
  (append load-path (list (expand-file-name "~/.emacs.d"))))
(setq auto-mode-alist 
     (append auto-mode-alist '(("\\.mmx\\|\\.amx" . mmx-mode))))
(autoload 'mmx-mode 
     "mmx-mode.el" "Major mode for editing Mathemagix files" t)

Once this is done, the mmx-mode will be loaded automatically for files with suffix .mmx or .amx.

Vim

The file mmxlight/syntax-highlighting/vim/mmx.vim provides syntax highlighting for Mathemagix code in Vim. It can be installed as follows:

mkdir -p $HOME/.vim/syntax/
cp mmxlight/syntax-highlighting/vim/mmx.vim $HOME/.vim/syntax/

To automatically apply this syntax highlighting to files with .mmx or .amx extension, add the following lines in the file $.vimrc:

au BufRead,BufNewFile *.mmx set filetype=mmx
au BufRead,BufNewFile *.amx set filetype=mmx

To use automatic indentation, add also the following line to $.vimrc:

autocmd FileType mmx setlocal expandtab shiftwidth=2 softtabstop=2 cindent

Nano

The file mmxlight/syntax-highlighting/nano/mmx.nanorc provides syntax highlighting for Mathemagix code in Nano. To use it, just add the following line to $.nanorc:

include "<mmx-path>/mmxlight/syntax-highlighting/nano/mmx.nanorc"

where <mmx-path> is the root of the Mathemagix source distribution.

Simple automatic indentation (reuse the indentation of the previous line) can be enabled by typing Meta-I in the editor. To enable this by default, add the following line to $.nanorc (see man nano and man nanorc for more details):

set autoindent

Gedit

The file mmxlight/syntax-highlighting/gedit/mmx.lang provides syntax highlighting for Mathemagix code in Gedit (Gnome's default text editor) and other gtksourceview-based editors.

To install it, you first need to check which gtksourceview version you are using (3.0 is most common, but some use 2.0 or 4 instead):

find /usr/share /usr/local/share -type d -name gtksourceview*
# output: /usr/[local/]share/gtksourceview-<version>

Then it suffices to copy mmx.lang to the appropriate location:

mkdir -p $HOME/.local/share/gtksourceview-<version>/language-specs/
cp mmxlight/syntax-highlighting/gedit/mmx.lang $HOME/.local/share/gtksourceview-<version>/language-specs/

Simple automatic indentation (reuse the indentation of the previous line) can be enabled in the preferences panel.

Kate/Kwrite

The file mmxlight/syntax-highlighting/kate/mmx.xml provides syntax highlighting and automatic C-style indentation for Mathemagix code in Kate/Kwrite (KDE's default text editor). It can be installed as follows:

mkdir -p $HOME/.local/share/org.kde.syntax-highlighting/syntax/
cp mmxlight/syntax-highlighting/kate/mmx.xml $HOME/.local/share/org.kde.syntax-highlighting/syntax/
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License. If you don't have this file, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.