help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Why call font-lock-add-keywords in a mode hook?


From: Marcin Borkowski
Subject: Why call font-lock-add-keywords in a mode hook?
Date: Mon, 25 Jan 2016 11:03:19 +0100
User-agent: mu4e 0.9.13; emacs 25.1.50.1

Hi list,

this I found in the manual:

--8<---------------cut here---------------start------------->8---
 -- Function: font-lock-add-keywords mode keywords &optional how
     This function adds highlighting KEYWORDS, for the current buffer or
     for major mode MODE.  The argument KEYWORDS should be a list with
     the same format as the variable ‘font-lock-keywords’.

     If MODE is a symbol which is a major mode command name, such as
     ‘c-mode’, the effect is that enabling Font Lock mode in MODE will
     add KEYWORDS to ‘font-lock-keywords’.  Calling with a non-‘nil’
     value of MODE is correct only in your ‘~/.emacs’ file.

     If MODE is ‘nil’, this function adds KEYWORDS to
     ‘font-lock-keywords’ in the current buffer.  This way of calling
     ‘font-lock-add-keywords’ is usually used in mode hook functions.
--8<---------------cut here---------------end--------------->8---

My question: why would I want to call this function in a hook if I can
specify the mode in its invocation?  (Assuming that I use it in my
init.el, of course.)

TIA,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University



reply via email to

[Prev in Thread] Current Thread [Next in Thread]