README for editing QMath files with Emacs. Table of contents: 1: QMath Emacs mode. 2: .emacs setup for QMath. 3: Additional setup for Emacs 20 and earlier. 1: QMath Emacs mode. The file "qmath-mode.el" is a major mode for editing QMath. This mode is derived from "python-mode.el": http://www.python.org/emacs/python-mode/ Provides syntax highlighting via font-lock, and basic navigation with imenu, using the reference identifiers found in the text, i.e., "[<-identifier]". At the moment it has lots of broken functionality, since I've tried to left as much of the original python-mode.el as possible. The only parts that somehow work are syntax highlighting and imenu navigation. Any other function that does something useful does so by coincidence. You can install and byte-compile it with the following commands: cp qmath-mode.el /usr/local/share/emacs/site-lisp/qmath-mode.el emacs --batch --no-init-file --eval "(byte-compile-file \"/usr/local/share/emacs/site-lisp/qmath-mode.el\")" To edit QMath documents, you need UTF-8 [http://www.unicode.org] support. From Emacs 21, this is built-in, but for Emacs 20 and earlier please read the section labelled "Additional setup for Emacs 20 and earlier". 2: .emacs setup for QMath. In Emacs 21, the Unicode support is built-in, so you no longer need the Mule-UCS package, although it would be a good idea to install the fonts anyway. This is probably not needed if you have XFree86 4.0 or later. For Emacs 20 and earlier, you will have to do the setup described in "Additional setup for Emacs 20 and earlier" in addition to the following. This is the suggested .emacs setup, common for Emacs 20 and 21: ----------8<------------------8<------------------8<---------------- ;; Generic font-lock settings. (require 'font-lock) (global-font-lock-mode t) (setq font-lock-maximum-decoration 3) ;; QMath. (setq auto-mode-alist (cons '("\\.qmath\\(\\.utf\\)?$" . qmath-mode) auto-mode-alist)) (autoload 'qmath-mode "qmath-mode" "Major mode for QMath documents." t) ;; Customizations for qmath-mode (defun my-qmath-mode-hook () ;; this will make sure spaces are used instead of tabs (setq indent-tabs-mode nil) ;; keybindings for QMath (define-key qmath-mode-map "\C-m" 'newline-and-indent) (define-key qmath-mode-map [tab] 'dabbrev-expand) ) (add-hook 'qmath-mode-hook 'my-qmath-mode-hook) ;; QMath files are always UTF-8. (modify-coding-system-alist 'file "\\.qmath\\(\\.utf\\)?" 'utf-8) ;; OMDoc. (setq auto-mode-alist (cons '("\\.omdoc\\(\\.utf\\)?$" . sgml-mode) auto-mode-alist)) ;; The following are some additional settings I find useful. ;; They are not related to QMath. ;; Show the file path in the title bar. (setq frame-title-format "Emacs: %f") ;; Highlight parent matching. (require 'paren) ;; Do not add lines automatically when the cursor goes to the end of the file. (setq next-line-add-newlines nil) ----------8<------------------8<------------------8<---------------- 3: Additional setup for Emacs 20 and earlier. For the "Unicode support" part, you will need to have the Mule-UCS package installed, with suitable fonts. There is detailed information in the following URL: http://www.cs.uu.nl/~otfried/Mule/ The following should go into your .emacs, before the generic QMath stuff: ----------8<------------------8<------------------8<---------------- ;; Unicode support. http://www.cs.uu.nl/~otfried/Mule/ (require 'oc-unicode) (if (eq window-system 'x) (progn (setq qmath-fontset (oc-create-fontset "-misc-fixed-medium-r-semicondensed--13-*-*-*-*-*-fontset-standard" "-misc-fixed-medium-r-*-ja-13-*-iso10646-*")) (oc-create-fontset "-misc-fixed-medium-r-*--15-*-*-*-*-*-fontset-standard" "-misc-fixed-medium-r-*-ja-15-*-iso10646-*") (oc-create-fontset "-misc-fixed-medium-r-normal--18-*-*-*-*-*-fontset-standard" "-misc-fixed-medium-r-normal-ja-18-*-iso10646-*") ) ) ----------8<------------------8<------------------8<---------------- Also, to make Emacs use the fontset you define as "qmath-fontset" above, you will have to insert the following line into "my-qmath-mode-hook": ----------8<------------------8<------------------8<---------------- (if (eq window-system 'x) (set-frame-font qmath-fontset) ) ----------8<------------------8<------------------8<----------------