Older changes in Lightning Completion/Ultra-TeX

Changes made 28 April 1998:


Bug fix in ultex-make-ref-from-label.

Changes made 17 April 1998:


Bug fix.

Changes made 7 April 1998:


Fixed a bug in ultex-grab-bibs, and reorganized some stuff.

Changes made 27 March 1998:


There are about a dozen changes. From the user's point of view, the most important ones are: ultex-grab-defs now works recursively on all input and include files. ultex-grab-commands now recognizes \DeclareMathSymbol. And hitting TAB (which runs ultex-tab-resume) now works better at resuming completion.

As far as the recursive command-grabbing goes, if you have an \input{bozo} command and you don't want the file bozo to be scanned by Ultra-TeX, put a space or TAB at the beginning of the line (before the \input command).

Changes made 23 March 1998:


Fixed bug in ultex-grab-commands, ultex-grab-labels.

Changes made 22 September 1997:


Made the font-lock stuff work with GNU Emacs 20.1 (at least on my machine). Some day soon I may rewrite ultex-setup.el (etc.) so that you can use the custom package to customize everything.

Changes made 1 August 1997:


Fixed a little bug in ultex-grab-bibs. This only affects things when this function is called in a buffer which is not associated to any file. (That's why I said "little bug.")

Changes made between 1 March 1997 and 31 July 1997:

I've reorganized the distribution: now there is a main directory called ultratex-0.3 (0.3 is the version number); it has subdirectories lisp, texi, and user, which contain, respectively, the main lisp code, the documentation (in texinfo format), and sample user customization files. Changing to the main directory and typing make all will byte-compile the lisp files and format the documentation into both info files and dvi files.


In response to changes in a recent version of AUC-TeX, I introduced a new variable, ultex-ignore-auctex-tex.el. If this is non-nil (the default), then the AUC-TeX file tex.el will not be loaded when requested by other files (such as tex-buf.el). If the only part of AUC-TeX that you use is the part that comes with Ultra-TeX (i.e., just the file tex-buf.el), then this change won't affect you. If you use more features of AUC-TeX than that, you should set this variable to be nil (although this may break some things in aucify.el). If I get a chance (or if Mark Hovey does), then we may clean this up a bit.


Fixed a few bugs.


Fixed a few bugs. Also, in ultex, added recognition for providecommand. ultra-tex-mode no longer runs text-mode-hook when it starts, because it shouldn't. It still runs tex-mode-hook, and of course ultra-tex-mode-hook. Furthermore, if you are typing on a line which has been commented out and you use a math-mode specific command (like a Greek key), ultra-tex won't beep at you. Similarly, if you use a math-mode specific command in the argument to \newcommand (etc.), it won't beep at you.


In response to unpopular demand (i.e., nobody has mentioned it, but I thought it was a good idea), I've started to include the files tex-buf.el and font-latex.el with the distribution. This way, users don't have to go around getting various things by ftp, and they get versions of these files that have been (at least cursorily) tested with Ultra-TeX.

Changes made between 15 February 1997 and 28 February 1997:


I incorporated the stuff in the file bufcomp.el into light.el, and removed bufcomp.el from the package.

Things regarding the *Completions* buffer were fixed up a bit, so that they seem to work with XEmacs. I also fixed one or two bugs.


This is a new file. Various changes in ultex.el make it incompatible with GNU Emacs 18, so ultex18.el patches the problems. If you use GNU Emacs 18, just make sure that both ultex.el and ultex18.el are in your load-path; ultex-setup.el will figure out which version of Emacs you are using, and load the appropriate thing. (GNU Emacs 18 requires both of these files, by the way.) ultex.el:

The Greek keymap stuff was rewritten a bit. This shouldn't have too much of an impact on anyone, I hope.

There is a new variable, ultex-dont-use-completion. If for some odd reason, you want to use Ultra-TeX mode, but you don't want to use lightning completion, then set this variable to t--i.e., put a line like this in your .emacs (or .ultex) file:

(setq ultex-dont-use-completion t)
Then you never enter lightning completion mode; instead, the TAB key tries to complete on TeX commands, using a new function, ultex-try-to-complete. I don't know how well this works yet, so let me know if you find problems.

I've introduced three new variables, ultex-match-braces, ultex-match-brackets, and ultex-match-parens. The default values are t, nil, and nil, respectively. If ultex-match-braces is non-nil, then hitting { inserts {} into the buffer (and similarly for the other two variables). So the default behavior of ultra-tex regarding insertion of braces, brackets, and parentheses hasn't changed, but it's easier to modify that behavior.

Changes made between 17 January 1997 and 14 February 1997:


Just a few bug fixes and things like that.


There is a new variable, ultex-rescan-after-new-label. If this is non-nil, then every time you enter a new \label, Emacs rescans your file for labels. This way, if you change a label, Emacs won't complete on the old one.

There is a new function, ultex-dont-use-completion. If for some odd reason, you want to use Ultra-TeX mode, but you don't want to use lightning completion, then add this function to your ultra-tex-mode-hook--i.e., put a line like this in your .emacs (or .ultex) file:

(add-hook 'ultra-tex-mode-hook 'ultex-dont-use-completion)
Then you never enter lightning completion mode; instead, the TAB key tries to complete on TeX commands. I don't know how well this works yet, so let me know if you find problems.

Changes made between 10 December 1996 and 16 January 1997:


I have enhanced the behavior of the dollar sign. For quite a while now, if you had $$ with the cursor between the dollar signs, then hitting $ would produce $$\n\n$$, and so on. This now works even if the math environment is not empty, so that if you have $x=y$ with the point somewhere between the dollar signs, hitting $ produces

with the cursor placed appropriately. In addition, if you have $x=y and Emacs can't find the closing $, then hitting $ puts a $ at the point. Similarly, if you have \begin{equation} and Emacs can't find the closing \end{equation}, it inserts that string wherever you hit $. These changes are quite recent, and I expect there to be a few bugs. Let me know if you find any.

I have also changed the default value of ultex-dollar-array. The entries are now:

 Starting delimiter        Ending delimiter
$                         $
\[                        \]
\begin{equation}\label{}  \end{equation}
\begin{equation*}         \end{equation*}
\begin{align}\label{}     \end{align}
\begin{align*}            \end{align*}
\begin{gather}\label{}    \end{gather}
\begin{gather*}           \end{gather*}
\begin{multline}\label{}  \end{multline}
\begin{multline*}         \end{multline*}
Note: there is (and has been for some time) a variable ultex-dollar-back. It determines the entry number, in this list, to start with after you have cycled through one time. The entries are numbered starting with 0, and this variable is set, by default, to 1. So if you have \begin{multline*} ... \end{multline*}, hitting $ changes this to \[ ... \]. Hence if you put
(setq ultex-dollar-back 0)
in your ultra-tex-mode-hook, then hitting $ would instead have produced $ ... $.

I changed ultex-math-mode, the function that tries to determine if the cursor is in a math environment or not. Now: it no longer beeps when you are entering arguments to \newcommand and \renewcommand, and it no longer treats the string \\[ as the start of a math environment, which it used to because it would only look at the substring \[.

There were some problems with comments and indentation and things; I think I have fixed them. (But in so doing, I have probably introduced some new problems. Oh well.) Along the way, I corrected an oversight, pointed out by Tom Roby: now \% is no longer treated as the start of a comment.


There are now functions lc-make-command-dark and lc-make-command-light for disabling and then re-enabling lightning completion on commands. For example, I use

(lc-make-command-dark 'dired-create-directory)
to disable lightning completion when using the function dired-create-directory. I can re-enable lightning completion for this command via
(lc-make-command-light 'dired-create-directory)
(Note: lc-make-command-light does not, all by itself, turn on lightning completion; it only turns it back on if you have temporarily turned it off for a particular command.)

I changed some things around so that file-name completion is a bit faster when looking at big directories, and you don't get that long pause anymore if the minibuffer says "/home/palmieri/" and you hit "/".

Changes made on 10 December 1996:


New file: this is a sample .emacs file for use with light.el.


New file: this is a sample .ultex file for use with ultex.el.

Changes made on 03 December 1996:


I removed the key binding on C-c C-g. This used to be bound to ultex-redefine-greek-key, but I don't think one should use that very much. And if I hit C-c accidentally, I want to be able to cancel it by hitting C-g.

Due to changes in lightnification, ultex-delete-csname (bound to C-c C-d) no longer completes on TeX commands. This will be fixed eventually.

There are several changes to ultex-grab-defs, the function that Ultra-TeX uses to find TeX commands. First, it now will search the buffer no farther than the first occurrence of "\end{document}" (if it can find that string), so if you put "\newcommand"s (or whatever) after that, they will be ignored by Emacs, just as they are ignored by LaTeX. Second, it ignores lines that are commented out.

Changes made on 02 December 1996:


Added a few things to lightnification. There is a new variable, lc-dark-recursive-minibufs. If this is a number N, then lightning completion will be disabled if the recursion depth is bigger than N; if this is non-nil but not a number, it's as if the value were 1. If it is nil, then lightning completion goes ahead normally.

Another new variable: lc-dark-commands. This is a list of commands for which lightning completion is disabled. For example, if you want one version of find-file which uses lightning completion and another that doesn't, give the following commands:

(lightnify 'files)     ;; enables lightning completion on file names
(defalias 'find-file-dark 'find-file)   ;; defines new command,
                       ;; find-file-dark, which acts like find-file
(setq lc-dark-commands (cons 'find-file-dark lc-dark-commands))
                       ;; adds find-file-dark to lc-dark-commands 
This way, find-file-dark will not use lightning completion.

Changes made on 27 November 1996:


Totally rewrote the lightnify function, at Richard Stallman's suggestion. Now, rather than using lightnify on particular functions, you use it on situations. For example, calling

(lightnify 'files)
turns on lightning completion whenever you enter a file name in the minibuffer. Calling (lightnify 'files) again turns this lightning completion off. Important: Before any of this will take effect, you have to give the command
(add-hook 'minibuffer-setup-hook 'lightning-completion)
Here are the arguments you can give to lightnify, and their effects:
    ARGUMENT          EFFECT: toggle lightning completion on
    'files             file names      (e.g., for C-x C-f)
    'commands          commands        (e.g., for M-x)
    'functions         lisp functions  (e.g., for C-h f)
    'variables         lisp variables  (e.g., for C-h v)
    'lisp-objects      lisp objects
    'user-variables    user variables
    'buffers           buffer names    (e.g., for C-x b)
    'info-menu-items   menu items in info   (e.g., when
                                        you hit m in Info-mode)
    'query             buffer contents when using query-replace
    'misc              everything else
There are two other possible arguments:
    'all      turn on lightning completion everywhere imaginable. 
    'none     turn off lightning completion everywhere.
Note that (lightnify 'query) requires the use of the bufcomp.el package, so if you use this, make sure bufcomp.el is in your load-path. Note: This version of lightning completion does not work in Emacs 18; if you are using Emacs 18, you have to stick to the old-fashioned version. (And see the notes on the file light18.el.)


This is a new file. The file light.el is now no longer completely compatible with Emacs 18. Instead, you should use light18.el, which in turn loads light.el. So you need to have both of these files in your load-path, and then run

(load "light18")
Since the lightnify function was changed rather dramatically in Emacs 19 (and XEmacs), the old version is now called lightnify18. So if you are using Emacs 18, you need to change all of your calls to lightnify to lightnify18.


This is a new file. It contains the old version of the lightnify function, in case you want to use that instead of the improved one. Load this file after you've loaded light.el.

Changes made on 21 November 1996:


Lightnified TeX-command-master, etc. Also added some code to determine whether to run xdvi with a landscape option or not.


Fixed changes from 20 November, so that imenu and bib-cite work well together or separately.

Changes made on 20 November 1996:


Two little changes: I defined a new function, called ultex-imenu-create-index, for imenu support. Also, ultra-tex-mode now runs tex-mode-hook when it starts up, as well as text-mode-hook and ultra-tex-mode-hook, which it has always run).


Added two new variables: ultex-use-imenu and ultex-use-bib-cite. If non-nil, these tell Ultra-TeX to use the imenu package and the bib-cite package, respectively. See ultex-setup.el for a bit more documentation.

Changes made on 19 November 1996:


Messed around a bit so that when you enter lightning completion mode, there is a menu called "Light" rather than a menu called "Minibuf" (the way there used to be).


(This is the file that adds the AUC-TeX feature of running (La)TeX on the current document, and things like that.) There were some bugs here--we left some things out when we were stealing things from the AUC-TeX package, and now we've put them back in.

Changes made on 14 November 1996:


First of all, I've changed the default key bindings for lightning completion, so that there is some consistency with the default Emacs completion. In particular, the TAB key opens up a *Completions* buffer with a list of possible completions; the RET key acts like LFD: it ends completion (and exits the minibuffer, if you're in the minibuffer). To cycle through the possible completions, you hit C-f. To cycle backwards, hit C-b. If you want to keep using the old keybindings, put the following in your .emacs file (before you load light.el):

(setq lc-use-old-lc-keymap t)
I've changed the documentation to take these changes into consideration.

(By the way, the more I play with the keymap code in light.el, the less satisfied I am with this code when combined with XEmacs. Some day I'll have to rewrite the keybindings for XEmacs, but getting things to work well with GNU Emacs 19 is my highest priority.)

Next, I've made the *Completions* buffer work better, at least in GNU Emacs 19. If you hit TAB (with the new key bindings), this buffer is opened, and it should say something like this at the top:

Click mouse-2 on a completion to select it.
In this buffer, type RET to select the completion near point.
(I suppose the first line might not be there, or it might be different, if you're not using X windows.) If you hit M-v (or the Page Up key), the cursor is moved to the *Completions* buffer. You can move around in this buffer as usual, and hitting RET selects the choice nearest the cursor as your completion.

Lastly, all the stuff discussed below about lc-override-flag may be unnecessary. I do not set this flag to t, and I never have any problems. So don't be too quick about changing the default setting of this variable.

I also changed the version number to 0.21.

Changes made between 6 November 1996 and 13 November 1996:


Back in August (or so), I changed light-mode so that it would work better with minor modes like outline mode that use C-c for a prefix character. Well, this produced a minor conflict: if you were in lightning completion mode and you hit RET to get a list of possible completions, you couldn't select one with the mouse the way you were supposed to. I don't feel like fixing this properly, so there is a temporary fix. By default now, the mouse thing will work, but you will have problems if you use minor modes that use C-c as a prefix character. To reverse this situation, put the following line in your .emacs file:

(setq lc-override-flag t)

Changes made between 27 October 1996 and 6 November 1996:

Started using version numbers. Since the packages are at least 6 years old, I decided to start with version 0.2.


Only the addition of a version number.


There are two major changes here. First of all, installation is different. Rather than having lines like

(defun tex-mode nil (interactive) (ultra-tex-mode))
(defun latex-mode nil (interactive) (ultra-tex-mode))
(defun LaTeX-mode nil (interactive) (ultra-tex-mode))
in your .emacs file, you instead load the file ultex-setup.el. For example, my .emacs file contains the following line:
(load "ultex-setup")
Other Ultra-TeX customization can be done either in .emacs, or in a file called .ultex. Here are the contents of my .ultex file, more or less:
(setq ultex-tree-file "~/tex/inputs/ultra-tex/textree.el"
      ultex-greek-keys-file "~/tex/inputs/ultra-tex/greek.el"
      ultex-latex-skel-file "~/tex/inputs/ultra-tex/skel.tex"
      ultex-alist-local-flag t
      ultex-use-color t
      ultex-use-font-latex t
      ultex-use-auctex t)

(add-hook 'ultra-tex-mode-hook
The file ultex-setup.el not only replaces the (defun tex-mode ...) lines, but (as you might infer from my .ultex file) it also does some other stuff: There are one or two other changes in ultex.el: it used to be that whenever you edited a TeX document, your tex-tree file would be open in some other buffer. That is no longer the case--now, your tex-tree file is opened, read, and then closed, whenever Emacs needs to read the default list of TeX commands; it does not hang around to clutter up your buffer list. Similarly, if you have a Greek keyboard displayed, once it is no longer visible, then that buffer is deleted (so you don't end up with lots of buffers called *greek keyboard* and things like that).

Changes made between 5 September 1996 and 27 October 1996:


Introduced a new variable, ultex-alist-local-flag. Its default value is nil; if you set it to be non-nil (in your .emacs file, for instance), then the ultex-current-alist will be buffer-local.

Changed ultex-grab-defs in two ways. First, in the old version, calling this function with some argument, say "bozo.tex", would leave you with the a buffer containing the file bozo.tex (so, for instance, ultra-tex-mode would be started for that file, and if you were using font-lock-mode in X windows, then the buffer would be fontified; all this caused a noticeable delay). In the new version, this shouldn't happen--a temporary buffer is created, scanned, and then deleted. Second, in the old version, if the variable ultex-alist-local-flag were non-nil, so that the ultex-current-alist were buffer-local, then grabbing definitions from another buffer would have no effect on the definitions in the current one. This has been changed, so that running ultex-grab-defs on the file bozo.tex adds the TeX commands from bozo.tex to the ultex-current-alist associated to the current buffer. (So if ultex-alist-local-flag is non-nil, then the commands from bozo.tex are only valid in the buffer from which you gave the ultex-grab-defs command; if the variable is nil, then those commands are valid in all buffers running ultra-tex-mode.)

Fixed a small bug in ultex-scan-bbl that caused problems with GNU Emacs 18.

Changes made between June 1996 and September 1996:


In GNU Emacs and XEmacs, gave light-mode its own minor-mode-keymap. This (mostly) shouldn't affect the behavior of lightning completion, but it should make the package a bit more compliant with guidelines set out by the GNU people. (The one way in which it might affect the behavior is as follows: if you are using some minor mode, like outline-mode, which makes use of the key C-c, then that definition of C-c would take precedence over the lightning completion one. So you couldn't stop lightning completion with C-c if you were using outline-mode. Now you can.)


Some of the default values for certain variables have been changed. For example, the variables ultex-math-start, ultex-math-end, paragraph-start, and paragraph-separate have been changed, so (in LaTeX2e, at least) hitting M-q to fill a paragraph works better than it did before.

Hitting the key M-X (that's meta-shift-x, not meta-x) gives \text{}, beeping if you're not in math mode.

Emacs understands the environment variable BIBINPUTS pretty well, so it can probably find your .bib file (if you use a \bibliography command, that is).

Changes made before June 1996:


One or two things were rewritten, but this shouldn't affect things from the user's viewpoint. (For instance, lightnification uses the minibuffer-setup-hook.) This was done to make the code cleaner and (I hope) more robust.

Light.el is now reasonably compatible with GNU Emacs 18, GNU Emacs 19, XEmacs. ("Reasonably compatible" means that it seems to work, as far as I've tested it. It doesn't mean that it is written in the most elegant and/or straightforward manner, or anything like that.) I've been using GNU Emacs 19, mainly, and I haven't noticed any glitches...


The behavior of the dollar key has been changed: now when you hit $ repeatedly, ultra-tex cycles through the elements of the variable ultex-dollar-array. The default setting is so that first you get $$, with the point in between the dollar signs, then $$\n\n$$ (\n means newline, so this means a pair of dollar signs, followed by two newlines, then another pair of dollar signs) with the point on the blank line, then \begin{equation}\label{}\n\n\end{equation} with the point inside the label argument, then \begin{equation*}\n\n\end{equation*}, then \begin{eqnarray}\n\n\end{eqnarray}, then \begin{eqnarray*}\n\n\end{eqnarray*}, then it goes back to $$\n\n$$. To modify this, in your .emacs file change the variable ultex-dollar-array, and also include the line

    (setq ultex-dollar-max (length ultex-dollar-array))
after you've set ultex-dollar-array. For instance, I use:
    (setq ultex-dollar-array
	("$$" . -1)
	("\\[\n\n\\]" . -3)
	("\\begin{equation}\\label{}\n\n\\end{equation}" . -17)
	("\\begin{equation*}\n\n\\end{equation*}" . -16)
	("\\begin{align}\\label{}\n\n\\end{align}" . -14)
	("\\begin{align*}\n\n\\end{align*}" . -13)
	("\\begin{gather}\\label{}\n\n\\end{gather}" . -15)
	("\\begin{gather*}\n\n\\end{gather*}" . -14)
	("\\begin{multline}\\label{}\n\n\\end{multline}" . -17)
	("\\begin{multline*}\n\n\\end{multline*}" . -16)
    (setq ultex-dollar-max (length ultex-dollar-array))
(The number at the end is how many spaces to move forward (well, backward, since they're all negative) from the end. So ("$$" . -1) means: insert "$$", then move backward 1 space.)

Fonts are handled a little differently, to take into account the difference between Latex 2.09 with the old font selection scheme and Latex 2e (and probably Latex 2.09) with the new font selection scheme. It used to be that meta-shift-e (a.k.a. M-E) would insert {\em }, with the point just inside the right brace. Now it inserts \emph{}, with the point inside the braces. Similarly, M-B used to insert {\bf }; now it inserts \mathbf{} or \textbf{}, depending on whether you're in math mode or not.

Ultra-tex is better at scanning your file for things on which to complete, when it first opens the file. Some new LaTeX commands (like \DeclareMathOperator) have been taken into account; ultra-tex also completes citation keys. For example, if you have a bibliography in your tex file with commands

    \bibitem{bozo} blah blah blah
    \bibitem{clown} blah blah blah
then \cite[]{bozo} and \cite[]{clown} will be added to the completion list (where the point goes inside the square brackets). The same holds if you are editing junk.tex and there is a file junk.bbl with \bibitem commands in it. (Caveat: these \bibitem commands need to appear between \begin{thebibliography} and \end{thebibliography} or else they will be ignored--this is true for both the tex file and the bbl file.) If your file junk.tex has a \bibliography command, such as
then (assuming you have the environment variable BIBINPUTS set), ultra-tex should be able to find the file bib-file.bib, scan it for things like
        author = "Bozo the Clown", etc.}
and then add \cite[]{bozo-clown} to its completion list.

Naturally, the "smart return key" knows about this sort of thing. If you have \cite[]{bozo}, and the cursor is in the empty square brackets, hitting RET deletes the brackets and moves you all the way past {bozo}. If you have \cite[Theorem A]{bozo}, hitting RET from anywhere inside the square brackets should move you all the way past {bozo}, without deleting the square brackets or their contents.

Last modified 28 April 1998.

Back to the Lightning Completion/Ultra-TeX home page.

Back to John Palmieri's home page.