From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jacob Gerlach Newsgroups: gmane.emacs.help Subject: Adding and running a major mode hook Date: Sat, 26 Apr 2014 10:25:52 -0700 (PDT) Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1398533431 25769 80.91.229.3 (26 Apr 2014 17:30:31 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 26 Apr 2014 17:30:31 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Apr 26 19:30:24 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1We6Qg-0007Us-DM for geh-help-gnu-emacs@m.gmane.org; Sat, 26 Apr 2014 19:30:22 +0200 Original-Received: from localhost ([::1]:35030 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1We6Qc-00051s-Nz for geh-help-gnu-emacs@m.gmane.org; Sat, 26 Apr 2014 13:30:18 -0400 X-Received: by 10.58.18.200 with SMTP id y8mr7705143ved.20.1398533152476; Sat, 26 Apr 2014 10:25:52 -0700 (PDT) X-Received: by 10.140.37.148 with SMTP id r20mr321620qgr.0.1398533152438; Sat, 26 Apr 2014 10:25:52 -0700 (PDT) Original-Path: usenet.stanford.edu!cm18no6614706qab.0!news-out.google.com!dz10ni23056qab.1!nntp.google.com!cm18no6614701qab.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=98.217.114.175; posting-account=Hx-_8AoAAACyMXgs4MCS3wNERNLct_lk Original-NNTP-Posting-Host: 98.217.114.175 User-Agent: G2/1.0 Injection-Date: Sat, 26 Apr 2014 17:25:52 +0000 Original-Xref: usenet.stanford.edu gnu.emacs.help:205118 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:97384 Archived-At: I think that a hook is the right way for me to allow users some customizati= on 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=20 (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 conce= ptual misunderstanding about the manner and sequence in which code in mymod= e.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)?