unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Adding and running a major mode hook
@ 2014-04-26 17:25 Jacob Gerlach
  2014-04-27  3:12 ` Eric Abrahamsen
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Jacob Gerlach @ 2014-04-26 17:25 UTC (permalink / raw)
  To: help-gnu-emacs

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 constructs.

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)?


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

end of thread, other threads:[~2014-04-29  0:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-26 17:25 Adding and running a major mode hook Jacob Gerlach
2014-04-27  3:12 ` Eric Abrahamsen
2014-04-27  5:15 ` Eric Abrahamsen
     [not found] ` <mailman.107.1398568207.1147.help-gnu-emacs@gnu.org>
2014-04-27 11:56   ` Jacob Gerlach
2014-04-27 12:10     ` Jacob Gerlach
2014-04-29  0:45     ` Eric Abrahamsen

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).