unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Void variable error in fontification code
@ 2016-11-11  2:29 Davin Pearson
  2016-11-11 16:04 ` Michael Heerdegen
  0 siblings, 1 reply; 2+ messages in thread
From: Davin Pearson @ 2016-11-11  2:29 UTC (permalink / raw)
  To: help-gnu-emacs

How come with the following lines of elisp code commented out:

;;(setq d-face-m4     'd-face-m4)
;;(setq d-face-m4-dnl 'd-face-m4-dnl)

I get the following error in my *Messages* buffer:

Error during redisplay: (jit-lock-function 9575) signaled (void-variable d-face-m4-dnl) [9 times]

Putting back the lines like so:

(setq d-face-m4     'd-face-m4)
(setq d-face-m4-dnl 'd-face-m4-dnl)

gets rid of the error messages.

I have the following lines of elisp code in my .emacs file:

(defun d-font-lock-add-begin (keywords)
  (if (fboundp 'font-lock-add-keywords)
      (font-lock-add-keywords nil keywords nil)
    (setq font-lock-keywords
          (append
           keywords
           font-lock-keywords))))

(d-font-lock-add-begin
  `(
      (,(concat "\\(\\<m4_" "dnl\\)\\(.$\\)") (1 d-face-m4-dnl t) (2 font-lock-comment-face))
   )
)



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Void variable error in fontification code
  2016-11-11  2:29 Void variable error in fontification code Davin Pearson
@ 2016-11-11 16:04 ` Michael Heerdegen
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Heerdegen @ 2016-11-11 16:04 UTC (permalink / raw)
  To: Davin Pearson; +Cc: help-gnu-emacs

Davin Pearson <davin.pearson@gmail.com> writes:

> (setq d-face-m4     'd-face-m4)
> (setq d-face-m4-dnl 'd-face-m4-dnl)

>       (,(concat "\\(\\<m4_" "dnl\\)\\(.$\\)") (1 d-face-m4-dnl t) (2 font-lock-comment-face))

I think you get confused by the fact that symbols are used as face
names.  For font lock keywords, faces are specified via face
expressions.  You specify a variable above, so its value has to be set
(to a face name), else you get the unbound error.

Instead, you can directly specify a face in form of a symbol, and since
this place is evaluated, you need to quote the name.

It's a bit weird in Emacs that faces effectively use a separate name
space, but they are specified as symbols, and in some cases, variables
having the same name as a face are bound to that face name (symbol).


Michael.



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-11-11 16:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-11  2:29 Void variable error in fontification code Davin Pearson
2016-11-11 16:04 ` Michael Heerdegen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).