[Top][All Lists]

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

Adding and running a major mode hook

From: Jacob Gerlach
Subject: Adding and running a major mode hook
Date: Sat, 26 Apr 2014 10:25:52 -0700 (PDT)
User-agent: G2/1.0

I think that a hook is the right way for me to allow users some customization 
in my major mode.

I have a list that is used to create font lock constructs, and I'd like to 
allow users to add to that list before my code processes it into font lock 

What I have now is basically:

(setq content-list...)

(mapc 'create-constructs content-list)

What I've tried to do is

 (setq content-list ...)

 (defvar add-user-content-hook nil)
 (defun add-user-content (input)
   (add-hook 'add-user-content-hook
     (lambda () (add-to-list 'content-list input))))

 (run-hooks 'add-user-content-hook)

 (mapc 'create-constructs content-list)

With the intention that users put something like 

  (add-user-content '("my content"))

in their .emacs

This code doesn't generate any errors, but it doesn't work either.

Reading about hooks in the documentation makes me think that I have a 
conceptual misunderstanding about the manner and sequence in which code in 
mymode.el is executed. Specifically, what is the difference between putting 
(run-hooks... in (define-derived-mode ... vs putting (run-hooks... somewhere in 
the mode's code (as I have done above)?

reply via email to

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