From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mark Elston Subject: Re: Hook Function Examples Date: Sun, 24 Jan 2010 22:21:21 -0800 Message-ID: <4B5D3861.400@comcast.net> References: <4B5CE87B.6060603@comcast.net> <2417.1264397075@gamaville.dokosmarshall.org> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NZIKN-0000t0-Pl for emacs-orgmode@gnu.org; Mon, 25 Jan 2010 01:21:35 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NZIKM-0000sM-Ac for emacs-orgmode@gnu.org; Mon, 25 Jan 2010 01:21:35 -0500 Received: from [199.232.76.173] (port=52281 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NZIKL-0000sJ-Gq for emacs-orgmode@gnu.org; Mon, 25 Jan 2010 01:21:33 -0500 Received: from qmta03.emeryville.ca.mail.comcast.net ([76.96.30.32]:34947) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NZIKL-00034x-3E for emacs-orgmode@gnu.org; Mon, 25 Jan 2010 01:21:33 -0500 In-Reply-To: <2417.1264397075@gamaville.dokosmarshall.org> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: org-mode emacs-orgmode On 1/24/2010 9:24 PM, Nick Dokos wrote: > Mark Elston wrote: > >> I am trying to make use of some of the hooks for exporting and haven't >> found any docs about what they take or how to make use of them (elisp >> is *not* my native language). >> > > The Emacs Lisp Reference manual has a section (23.1: Hooks) on hooks, > but I'm not sure how helpful it will be to you. The most important note > is that "normal" hook variables are, by convention, named > -hook. "normal" means that the functions that are added to the hook > take no arguments and return no useful values. > >> In particular, I am trying to figure out how to use the following >> to see if any of them are going to help me: >> >> org-export-preprocess-hook >> org-export-preprocess-after-tree-selection-hook >> org-export-preprocess-final-hook >> >> Any examples of a hook function for these would help a lot. In >> particular, what are the parameters, is the point "looking at" >> anything in particular, etc. >> > > Use the source, Luke! (erm... Mark!) > > C-h v org-export-preprocess-hook > > gives me: > > (org-export-blocks-preprocess) > Thanks, Nick. I had checked a few hooks (but not that one) and couldn't find any that had any functions assigned. > so we have here an example of a hook function! > > C-h f org-export-blocks-preprocess > > gives you the function's doc string, including a link to where it is > defined, and clicking on the link will take you to the function: no > params (it is a "normal" hook after all), and I think you can make no > assumptions about the context. In particular, the above function wraps > everything in a save-excursion, goes to the beginning of the buffer and > searches for interesting things, doing something on each interesting > thing it finds. OK. From what I read I am assuming that a buffer is created with some already-processed (though not completely) org data as its initial content. Then, at some point, these hook functions are called on this new buffer. I assume this is the case since you wouldn't want to go modifying the original buffer - though this is not stated anywhere that I can find. Some hook functions apparently *do* take parameters (e.g. org-cycle-hook, etc) and I wasn't sure about the ones that didn't mention any. I was just trying to find my way and didn't have a map of what was where. Even the org-export-blocks-preprocess() function is a little difficult to wade through for someone not really familiar with elisp. I think I have pieced it together, though. This may give me what I need to do what I want (remove some specific kinds of headers when creating certain LaTeX files). Are my assumptions above correct, then? Mark