Subject: bug#1074: antlr-mode has undefined variable keyword-face

From: "David J. Biesack" <[email-masked]>
Date: Fri, 03 Oct 2008 10:05:39 -0400

Open a .g file in Emacs, where auto-mode-alist configures
.g files to use antlr-mode. You get an error in font-lock
code because of an undefined variable, 'keyword-face'

This patch appears to resolve the problem:

diff -cws antlr-mode.el.orig antlr-mode.el
*** antlr-mode.el.orig  Fri Oct  3 09:58:33 2008
--- antlr-mode.el       Sun Jan 14 03:46:56 2007
***************
*** 922,928 ****
     `((antlr-invalidate-context-cache)
       ("\\$setType[ \t]*(\\([A-Za-z\300-\326\330-\337]\\sw*\\))"
        (1 antlr-tokendef-face))
!      ("\\$\\sw+" (0 antlr-keyword-face))
       ;; the tokens are already fontified as string/docstrings:
       (,(lambda (limit)
         (if antlr-font-lock-literal-regexp
--- 922,928 ----
     `((antlr-invalidate-context-cache)
       ("\\$setType[ \t]*(\\([A-Za-z\300-\326\330-\337]\\sw*\\))"
        (1 antlr-tokendef-face))
!      ("\\$\\sw+" (0 keyword-face))
       ;; the tokens are already fontified as string/docstrings:
       (,(lambda (limit)
         (if antlr-font-lock-literal-regexp

Debugger entered--Lisp error: (void-variable keyword-face)
  eval(keyword-face)
  font-lock-fontify-keywords-region(1 1979 t)
  font-lock-default-fontify-region(1 1979 t)
  font-lock-fontify-region(1 1979 t)
  byte-code("Ã ÄÅed      #Æ Ç+" [save-match-data-internal verbose font-lock-fontified match-data ((byte-code "ÁÂ\"" [save-match-data-internal set-match-data evaporate] 3)) font-lock-fontify-region font-lock-after-fontify-buffer t] 4)
  font-lock-default-fontify-buffer()
  font-lock-fontify-buffer()
  font-lock-mode-internal(t)
  font-lock-default-function(t)
  font-lock-mode()
  turn-on-font-lock()
  turn-on-font-lock-if-enabled()
  global-font-lock-mode-enable-in-buffers()
  run-hooks(after-change-major-mode-hook)
  run-mode-hooks(antlr-mode-hook)
  antlr-mode()
  set-auto-mode-0(antlr-mode nil)
  set-auto-mode()
  normal-mode(t)
  after-find-file(nil t)
  find-file-noselect-1(#<buffer Greet.g> "~/eclipse-workspaces/acl/antlr_test/source/java/Greet.g" nil nil "~/eclipse-workspaces/acl/ANTLR_test/Source/Java/Greet.g" (26662 (36053 . 4313)))
  ad-Orig-find-file-noselect("~/eclipse-workspaces/acl/antlr_test/source/java/Greet.g" nil nil nil)
  byte-code("ÆÇ       !
$)" [ad-return-value filename dir nowarn rawfile wildcards nil file-name-directory downcase file-name-nondirectory ad-Orig-find-file-noselect] 6)
  find-file-noselect("~/eclipse-workspaces/acl/ANTLR_test/Source/Java/Greet.g" nil nil nil)
  find-file("~/eclipse-workspaces/acl/ANTLR_test/Source/Java/Greet.g")
  byte-code("Â 
  new-find-alternate-file("~/eclipse-workspaces/acl/ANTLR_test/Source/Java/Greet.g")
  call-interactively(new-find-alternate-file)
  recursive-edit()
  byte-code("Æ        @Ç=!
VW
¥y`dbÒ
¥
Zy`|)ÓcebÔÕÖ \"× ÔØ!ÙÊÔØ!Ú +Ù" [unread-command-char debugger-args x debugger-buffer noninteractive debugger-batch-max-lines -1 debug backtrace-debug 4 t backtrace-frame lambda 5 pop-to-buffer debugger-mode debugger-setup-buffer count-lines 2 "...\n" message "%s" buffer-string kill-emacs "" nil recursive-edit middlestart buffer-read-only standard-output] 4)
  debug(error (void-variable keyword-face))
  apply(debug error (void-variable keyword-face))
  edebug(error (void-variable keyword-face))
  eval(keyword-face)
  font-lock-fontify-keywords-region(1 1979 t)
  font-lock-default-fontify-region(1 1979 t)
  font-lock-fontify-region(1 1979 t)
  byte-code("Ã ÄÅed      #Æ Ç+" [save-match-data-internal verbose font-lock-fontified match-data ((byte-code "ÁÂ\"" [save-match-data-internal set-match-data evaporate] 3)) font-lock-fontify-region font-lock-after-fontify-buffer t] 4)
  font-lock-default-fontify-buffer()
  font-lock-fontify-buffer()
  font-lock-mode-internal(t)
  font-lock-default-function(t)
  font-lock-mode()
  turn-on-font-lock()
  turn-on-font-lock-if-enabled()
  global-font-lock-mode-enable-in-buffers()
  run-hooks(after-change-major-mode-hook)
  run-mode-hooks(antlr-mode-hook)
  antlr-mode()
  set-auto-mode-0(antlr-mode nil)
  set-auto-mode()
  normal-mode(t)
  after-find-file(nil t)
  find-file-noselect-1(#<killed buffer> "~/eclipse-workspaces/acl/antlr_test/source/java/Greet.g" nil nil "~/eclipse-workspaces/acl/ANTLR_test/Source/Java/Greet.g" (26662 (36053 . 4313)))
  ad-Orig-find-file-noselect("~/eclipse-workspaces/acl/antlr_test/source/java/Greet.g" nil nil nil)
  byte-code("ÆÇ       !
$)" [ad-return-value filename dir nowarn rawfile wildcards nil file-name-directory downcase file-name-nondirectory ad-Orig-find-file-noselect] 6)
  find-file-noselect("~/eclipse-workspaces/acl/ANTLR_test/Source/Java/Greet.g" nil nil nil)
  find-file("~/eclipse-workspaces/acl/ANTLR_test/Source/Java/Greet.g")
  byte-code("Â 
  new-find-alternate-file("~/eclipse-workspaces/acl/ANTLR_test/Source/Java/Greet.g")
  call-interactively(new-find-alternate-file)

In GNU Emacs 22.1.1 (i386-mingw-nt5.1.2600)
 of 2007-06-02 on RELEASE
Windowing system distributor `Microsoft Corp.', version 5.1.2600
configured using `configure --with-gcc (3.4) --cflags -Ic:/gnuwin32/include'

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: ENU
  locale-coding-system: cp1252
  default-enable-multibyte-characters: t

Major mode: Antlr.Java/l

Minor modes in effect:
  display-time-mode: t
  shell-dirtrack-mode: t
  delete-selection-mode: t
  pc-selection-mode: t
  show-paren-mode: t
  iswitchb-mode: t
  encoded-kbd-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  unify-8859-on-encoding-mode: t
  utf-translate-cjk-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t
  abbrev-mode: t

Recent input:
<escape> X M-b M-b M-b M-b C-b C-b C-b C-d C-e <return> 
M-< C-x * c d SPC ~ / e m a c s <return> C-x o <escape> 
X M-b C-M-f C-SPC M-b M-b M-b M-b M-b M-b M-w C-g C-x 
o C-y <return> C-x o <escape> <escape> ( g e t e n 
v SPC " T E R M " ) <return> C-x C-o C-x o e c h o 
SPC $ T E R M <return> e x p o r t SPC T E R M = c 
m d <return> M-p M-p M-p <return> C-x o C-v C-x k SPC 
C-x B C-x B C-x o C-x j E M-< C-x C-f <backspace> M-b 
. C-e <return> C-s k e y w o r d - C-w C-s C-s C-s 
C-s C-a C-x o C-n C-n C-n C-x o C-x b a n t <return> 
C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s C-a M-< M-x 
p w d <return> <help-echo> <down-mouse-1> <mouse-1> 
C-s a n t l r - <backspace> <backspace> <backspace> 
<backspace> <backspace> <backspace> SPC k e y w o r 
d - C-SPC M-b C-SPC a n t l r - C-s C-w C-w C-s C-a 
C-SPC C-o C-o C-o C-o C-o M-x e a l <backspace> <backspace> 
v a l - d e f SPC <return> M-x C-g C-/ C-x C-w a n 
l SPC <backspace> t SPC . r <backspace> o r i g <return> 
a n t l r - C-a C-x C-s C-x c M-x e v a l - d e SPC 
<return> C-x o C-x b G r e e <return> C-/ C-SPC C-x 
k SPC C-z 0 C-n C-n C-n <down-mouse-1> <mouse-1> M-x 
r e p o r t - SPC <return>

Recent messages:
undo-start: No undo information in this buffer
Mark set
Kill buffer Greet.g? (y or n) 
Invalid face reference: font-lock-keyword-face [43 times]
Invalid face reference: highlight
Invalid face reference: font-lock-keyword-face
Invalid face reference: highlight [2 times]
Fontifying Greet.g... (regexps......................)
Fontifying Greet.g... (regexps......................)
Loading emacsbug...done

-- 
David J. Biesack     SAS Institute Inc.
(919) 531-7771       SAS Campus Drive
http://www.sas.com   Cary, NC 27513