[ESS] ESS and font-lock support.

gerald.jean at dgag.ca gerald.jean at dgag.ca
Fri Dec 17 14:42:57 CET 2010


Hello,

a little while ago I sent posted to this list regarding problems with font
locking in an upgrade from Emacs 21.3 to 23.2.  Unfortunately no one could
provide a solution.  Since the problem kept recurring and was very annoying
to me, yesterday I posted the following on the "gnu-emacs-help" list.  With
the help of Drew Adams I found the problem, which is related to ESS, and at
his suggestion I am getting back to this list so the problem could be
permanently fixed.  Here it is:

I am using Emacs-23.2 on a RedHat 64-bit box.  Ever since IT upgraded from
21.3 to 23.2 I have problems with just one face, namely "Font Lock Type
Face".  Every time I restart Emacs I have to do the following:

1.- M-x customize-group «enter»
2.- font-lock-faces «enter»
3.- Then move down to the "Font Lock Type Face", it is always set to
Goldenrod (which is unreadable on the                 background color I am
using for years).
4.- Then change the Foreground entry from Goldenrod to OrangeRed (for
example).
5.- Then move back to top of buffer, click the «Set for current session»
button and the «Save for future sess      ions button», reply «yes» to the
asked question about saving the current settings.
6.- Exit customize

The settings have been applied and are OK, and stay that way for the time
the current session remains open .
Next time I restart Emacs I am at square 1 again.

Customize has written the following code to my «.emacs» file, and this is
the last statement in my «.emacs» file:

(custom-set-faces
  ;; custom-set-faces was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.
 '(default ((t (:inherit nil :stipple nil :background "LightBlue"
:foreground "Maroon" :inverse-video nil :box nil :strike-through nil
:overline nil :underline nil :slant normal :weight bold :height 137 :width
normal :foundry "b&h" :family "lucidatypewriter"))))
 '(dired-header ((t (:inherit default :foreground "OrangeRed"))))
 '(font-lock-type-face ((t (:foreground "OrangeRed"))))
 '(outline-5 ((t (:inherit font-lock-type-face :foreground "OrangeRed")))))

------- Drew Adams
---------------------------------------------------------------------------

Try (after backing up your .emacs) using a different .emacs that has only
this
in it:

(custom-set-faces
  '(font-lock-type-face ((t (:foreground "OrangeRed")))))

If that works, then try commenting out half of your original .emacs
(leaving the
`custom-set-faces'), then comment-out 3/4, 7/8, 15/16,... until you find
which
part of your init file is interfering.

In sum, play around a little, varying things, to see what you can discover.

------- Gérald Jean
----------------------------------------------------------------------------

This is what I did and thanks to Drew I located the problem.
I would never have thought of looking there though since the problem
originates from an Emacs package I use very heavily, every day, for
years, ess (Emacs Speaks Statistics), furthermore, the problem
occurred after the upgrade from 21.3 to 23.2, it was OK before?

(require 'ess-site)
(require 'ess-font-lock)
(ess-font-lock-db)  ;;  This single function caused the problem.

I went to "ess-font-lock.el" and found:

(defun ess-font-lock-db ()
  "Set font-lock colors (leave fore-/back-ground alone) courtesy David
Brahm <David.Brahm at fmr.com>"
  (interactive)
  (set-face-foreground 'font-lock-comment-face       "Firebrick")  ; #...
%...
  (set-face-foreground 'font-lock-string-face        "SeaGreen")   ; "..."
"..."
  (set-face-foreground 'font-lock-keyword-face       "MediumBlue") ; if
\end
  (set-face-foreground 'font-lock-function-name-face "VioletRed")  ; talk<-
{center}
  (set-face-foreground 'font-lock-variable-name-face "Blue")         ; xv
  (set-face-foreground 'font-lock-type-face          "Goldenrod")  ; T,F
?
  (set-face-foreground 'font-lock-constant-face      "Magenta")    ; <-
{eq1}
)
---------- Drew Adams
---------------------------------------------------------------------------

Is that `(ess-font-lock-db)' occurrence at the top level of some file that
you
load?  IOW, is it getting eval'd unconditionally whenever you load ESS?

If so, I would recommend that you file an ESS bug.
Merely loading a library should not change user settings this way.

Some reasonable ways for a library to deal with this kind of thing:

a. Just recommend particular settings, in a comment or doc string, without
actually setting them.

b. Provide a command that sets the recommended settings.

c. Provide its own user options or faces with the recommended values as the
default values.  That way, users can customize them.

----------- Gérald Jean
---------------------------------------------------------------------

I replaced the offending "Goldenrod" by "OrangeRed" and everything is fine,
the only thing now is that at each upgrade I'll have to remember to change
this!

---------- Drew Adams
-----------------------------------------------------------------------

That's why it's better to file a bug report.
You should not need to modify source code that way.
_________________________________________________________________________________________________

By the way, I am running ESS 5.12, but it was the same with 5.11.  And it
never happened, in years of heavy using, before Emacs 23.2, don't know
about Emacs 22, our IT skiped over this one.

Thanks for looking into this, if I can help in any ways let me know.

Gérald Jean
Conseiller senior en statistiques,
VP Actuariat et Solutions d'assurances,
Desjardins Groupe d'Assurances Générales
télephone            : (418) 835-4900 poste (7639)
télecopieur          : (418) 835-6657
courrier électronique: gerald.jean at dgag.ca

"We believe in God, others must bring Data."

W. Edwards Deming


More information about the ESS-help mailing list