Tuesday 19 June 2012

Where did my constants go?

I just installed Emacs 24.1 on Mac OS X Lion, and found that my Ada code seemed to have been eaten away.

For example, if the code said

   "with Foo;”

it would appear as

   "with    ;”

giving this sort of effect:

This is to do with colouring in font-lock-mode; the Foo is displayed in font-lock-constant-face which is set by default to “dark cyan".

The change in Emacs appears to be that if it doesn't recognise the face it displays in background (white), whereas before it used to display in black; resulting in white-on-white.

The fix is to change the face to something that Emacs does recognise, for example “cyan4”.

  1. In Emacs, put point on an area of invisible text.
  2. From the menubar (which may be subtly different on other operating systems, of course), select Options > Customize Emacs > Specific Face...
  3. The Minibuffer should say “Customize face (default `font-lock-constant-face’): ”; press Ret.

You should now see something like

Change the “dark cyan” to “cyan4” - or whatever colour takes your fancy - and press Set for current session, to test it out on your code, then Save for future sessions to keep the setting.

1 comment:

  1. Of course, I could have checked on Google: the problem appears to be caused by an old version of Emacs (from 2005) leaving droppings[1].

    Remove ~/Library/Colors/Emacs.clr, restart Emacs, and all is well.

    [1] http://permalink.gmane.org/gmane.emacs.macintosh.osx/6639

    ReplyDelete