History Of Font Lock In Emacs

Someone on Reddit (ieure) asked for the etymology of the Emacs term “font lock”, and hypothesised that it was due to jwz (https://www.jwz.org)..) So I asked jwz, who kindly told me.


March 21, 2019 8:16 PM, “Jamie Zawinski” wrote:

WOW! DEEP LORE!!!

I do not the Reddits, but feel free to share this. Yes, it was me, -ish.

The following is the earliest expression of this, Jan 1989, which I later built into Lucid Emacs in, let’s say, 1992?

It’s important to understand that the TI Explorer Lisp Machine keyboard had several hardware keys – with toggle-button, non-momentary lock LEDs – that by default did nothing, so I felt it my mission to solve that problem:

http://bunny.xeny.net/linked/TI-Explorer-Lisp-Machine-keyboard.png

The LispM compiler understood certain escape sequences to be mere “character styles” and it ignored those escape sequences, so you could include binary-encoded “stylizations” into your source code and it would still work. It was like a simple, proto-utf8.

So based on the “-Lock” suffix encoded/printed on those non-functional hardware keys, I build LispM code that made them do something, and then later build Lucid Emacs code with a similar naming scheme, because (to be honest, and I’m sure this is not really a surprise) Lucid Emacs was my attempt to port the Lisp Machine development environment to Unix (under the guise of the Lucid Energize system, which was, kinda, the first Unix IDE, before the term even existed. We did some stuff, ok?)

So here it is:

Date: Mon, 30 Jan 1989 16:16:49 -0700 From: Dirt Behind the Daydream Subject: new winning hack To: ALL

The file Ronin:JWZ.HACKS;BOLD-LOCK.LISP contains code that enables the “Bold Lock” and “Italic Lock” keys up at the top of the keyboard. This file defines a ZMACS minor-mode that looks at the Bold and Italic lock keys and sets the current font appropriately.

If Bold-Lock Mode is on in a buffer, the following behavior is exhibited:

o Make the current font be the font which corresponds to the current font modified by the Bold and Italic lock keys - for example, if the current font was TR12, TR12b, TR12i, or TR12bi, and the italic lock key was lit but the bold lock key was not, then the resultant font would be TR12i.

If Bold-Lock Mode attempts to make the current font be one which is not in the font list of the current buffer, the user is asked whether to add this font to the font list. If the user replies no, then Bold-Lock Mode will not ask again about that particular font - subsequent attempts to change to that font will be no-ops.

o If both “Bold-Lock Mode” and “Electric Font-Lock Mode” are on at the same time, the behavior is slightly different. When Bold-Lock Mode is determining the current font, it “maximizes” the facecode of the font - that is, if the current font is italic, but the Bold Lock key is lit and the Italic Lock key is not, then the resultant font will be Bold-Italic.

Suppose the user has told “Electric Font-Lock Mode” that all docstrings are to be printed in the font TR12I. If the interaction between Bold-Lock Mode and Electric Font-Lock Mode was different, then unless the user always hit Italic Lock before typing docstrings, docstrings would come out in TR12 instead of the requested TR12i.

Also, if the user is typing in a docstring, and the docstring font is TR12i, the user may produce TR12bi merely by hitting the Bold Lock key.

You turn this on by saying “Meta-X Bold Lock Mode”. Or, put in your login file the form:

            (setq *initial-minor-modes* `(any-bracket-mode bold-lock-mode [Zetalisp-mode Common-lisp-mode) Electric-font-lock-mode)
                ((text-mode) Auto-fill-mode)
            ]()

This says that all buffers default to having “Bracket” and “Bold-Lock” modes on, Lisp buffers default to that plus “Font-Lock” mode, and Text buffers default to that plus “Fill” mode.

– jwz