This section gives examples of initialization code that should be put into ~/.emacs or ~/.xemacs/init.el. Since much of this code is spread over several code chunks it is probably useful to execute
notangle -Remacscode allprose.tex.nw > emacs.el
|
and then cut and paste the appropriate lines from that file.
For the use of the inverse search facility of xdvi and kdvi, it is convenient not start a new Emacs every time you click in the xdvi window. See also Section24.3.9.
Through the following code file patterns are associated with modes.
It is quite useful to load AUCTEX and syntax highlighting.
My aldor-mode supports syntax highlighting and indenting Aldor code, but consult its documentation for more details.
aldor-mode is itself a literate program, so tangle and weave it.
notangle aldor.el.nw > aldor.el
noweave aldor.el.nw > aldor.tex |
Suppose you put the file aldor.el into the directory ˜/elisp. Then you should put the following code into your ~/.emacs or ~/.xemacs/init.el and restart Emacs. See also the definition of auto-mode-alist in Section 9.3.
The aldor-mode works fine with mmm-mode.
The multiple major mode (mmm-mode) is useful for editing code and documentation of .nw files in Emacs.
Setup can be done as follows.
EMACS=/usr/bin/emacs ./configure --prefix ~/elisp/mmm
make make install |
Be careful to compile for the flavour (Emacs or XEmacs) you use, see below.
First, the setup for mmm-mode in general and its association to certain file types.
The following code is partly taken from Emacs (subr.el assoc-default), because the function assoc-default is not available in XEmacs.
It takes a string (key) and tries to string-match the car (first of a list) of an element of auto-mode-alist against key. If found, it returns the cdr (rest of the list) of the matching pair. If not found then fundamental-mode is returned.
Note that an element of auto-mode-alist can either be a dotted pair or an atom. In the latter case, this atom is returned if it matches key. (Maybe that makes not much sense here, but we did not want to deviate too much from assoc-default.
We need get-auto-mode to set the mmm-noweb-code-mode depending on the file type. Whenever mmm-mode is switched on, the hook below tests whether the filename ends in .pamphlet or .nw. This extension is removed and the filename is matched against the auto-mode-alist. From the latter we get via the function get-auto-mode the corresponding mode that will then be assigned to mmm-noweb-code-mode.
You could put
% -*- mode: latex; mmm-noweb-code-mode: makefile-mode; -*-
|
at the beginning of your file.
Or, at the end of a .nw file say something like
%EMACS Local Variables:
%EMACS mmm-noweb-code-mode: makefile-mode %EMACS End: |
where, of course, makefile-mode has to be replaced by the mode that is appropriate for the code inside the code chunks, e. g., aldor-mode.
Of course, it is undesirable to put extra Emacs specific code into a source file, since one cannot expect that everyone is using Emacs.
Unfortunately, for XEmacs the setup is not identical. First of all, you will have to say
EMACS=/usr/bin/xemacs ./configure --prefix ~/elisp/mmm
|
and the above code goes into the file ~/.xemacs/init.el.
I have not investigated the reason for the following. Additionally, I had to add the preview-latex package (version 0.7.8) into the directory ˜/.xemacs/xemacs-packages in order to make mmm-mode work.
There is not much help in case the LATEX compilation of the dvi file fails. There are, however two files that can be investigated in order to find the reason for the error. The file myalps.trace is generated via
latex projectname.tex >> projectname.trace
|
The file myalps.log is the by default generated by LATEX itself.
One suggestion is to look into these files and search backwards for the extension .nw.tex in order to figure out in which file the error occurred. Note that you should edit the corresponding .nw file, since the .nw.tex file is generated on the fly.
Here we describe the case if the compilation of the library is started from within Emacs via the command
M-x compile RET cd $RootToProject; make RET
|
and fails. Emacs provides the command next-error. Calling it via
M-x next-error RET
|
lets Emacs load the corresponding file and jump directly to the error position.
You can bind the above command to a key. For example, put the following code into the ~/.emacs or the ~/.xemacs/init.el file.