Update the hook list, and add an example for org-agenda-after-show-hook
[Worg/babel-doc.git] / org-configs / org-hooks.org
blobf8389ada18c6ddf7e38acba72185736f3f255647
1 #+OPTIONS:    H:3 num:nil toc:t \n:nil @:t ::t |:t ^:t -:t f:t *:t TeX:t LaTeX:t skip:nil d:(HIDE) tags:not-in-toc
2 #+STARTUP:    align fold nodlcheck hidestars oddeven lognotestate
3 #+SEQ_TODO:   TODO(t) INPROGRESS(i) WAITING(w@) | DONE(d) CANCELED(c@)
4 #+TITLE:      List of org-mode hooks - examples of use
5 #+AUTHOR:     Worg people
6 #+EMAIL:      bzg AT altern DOT org
7 #+LANGUAGE:   en
8 #+PRIORITIES: A C B
9 #+CATEGORY:   worg
11 # This file is the default header for new Org files in Worg.  Feel free
12 # to tailor it to your needs.
14 [[file:index.org][{Back to Worg's index}]]
16 This is the list of Org-mode hooks and function variables, with their
17 documentation strings:
19 * Hooks and Function variables
21 ** =org-load-hook=
22 Defined in: /org.el/
23 #+begin_example
24     Hook that is run after org.el has been loaded.
25 #+end_example
26 ** =org-pre-cycle-hook=
27 Defined in: /org.el/
28 #+begin_example
29     Hook that is run before visibility cycling is happening.
30     The function(s) in this hook must accept a single argument which indicates
31     the new state that will be set right after running this hook.  The
32     argument is a symbol.  Before a global state change, it can have the values
33     `overview', `content', or `all'.  Before a local state change, it can have
34     the values `folded', `children', or `subtree'.
35 #+end_example
36 ** =org-cycle-hook=
37 Defined in: /org.el/
38 #+begin_example
39     Hook that is run after `org-cycle' has changed the buffer visibility.
40     The function(s) in this hook must accept a single argument which indicates
41     the new state that was set by the most recent `org-cycle' command.  The
42     argument is a symbol.  After a global state change, it can have the values
43     `overview', `content', or `all'.  After a local state change, it can have
44     the values `folded', `children', or `subtree'.
45 #+end_example
46 ** =org-insert-heading-hook=
47 Defined in: /org.el/
48 #+begin_example
49     Hook being run after inserting a new heading.
50 #+end_example
51 ** =org-occur-hook=
52 Defined in: /org.el/
53 #+begin_example
54     Hook that is run after `org-occur' has constructed a sparse tree.
55     This can be used to recenter the window to show as much of the structure
56     as possible.
57 #+end_example
58 ** =org-make-link-description-function=
59 Defined in: /org.el/
60 #+begin_example
61     Function to use to generate link descriptions from links. If
62     nil the link location will be used. This function must take two
63     parameters; the first is the link and the second the description
64     org-insert-link has generated, and should return the description
65     to use.
66 #+end_example
67 ** =org-link-translation-function=
68 Defined in: /org.el/
69 #+begin_example
70     Function to translate links with different syntax to Org syntax.
71     This can be used to translate links created for example by the Planner
72     or emacs-wiki packages to Org syntax.
73     The function must accept two parameters, a TYPE containing the link
74     protocol name like \"rmail\" or \"gnus\" as a string, and the linked path,
75     which is everything after the link protocol.  It should return a cons
76     with possibly modified values of type and path.
77     Org contains a function for this, so if you set this variable to
78     `org-translate-link-from-planner', you should be able follow many
79     links created by planner.
80 #+end_example
81 ** =org-follow-link-hook=
82 Defined in: /org.el/
83 #+begin_example
84     Hook that is run after a link has been followed.
85 #+end_example
86 ** =org-confirm-shell-link-function=
87 Defined in: /org.el/
88 #+begin_example
89     Non-nil means, ask for confirmation before executing shell links.
90     Shell links can be dangerous: just think about a link
91     
92          [[shell:rm -rf ~/*][Google Search]]
93     
94     This link would show up in your Org-mode document as \"Google Search\",
95     but really it would remove your entire home directory.
96     Therefore we advise against setting this variable to nil.
97     Just change it to `y-or-n-p' if you want to confirm with a
98     single keystroke rather than having to type \"yes\".
99 #+end_example
100 ** =org-confirm-elisp-link-function=
101 Defined in: /org.el/
102 #+begin_example
103     Non-nil means, ask for confirmation before executing Emacs Lisp links.
104     Elisp links can be dangerous: just think about a link
105     
106          [[elisp:(shell-command \"rm -rf ~/*\")][Google Search]]
107     
108     This link would show up in your Org-mode document as \"Google Search\",
109     but really it would remove your entire home directory.
110     Therefore we advise against setting this variable to nil.
111     Just change it to `y-or-n-p' if you want to confirm with a
112     single keystroke rather than having to type \"yes\".
113 #+end_example
114 ** =org-refile-target-verify-function=
115 Defined in: /org.el/
116 #+begin_example
117     Function to verify if the headline at point should be a refile target.
118     The function will be called without arguments, with point at the
119     beginning of the headline.  It should return t and leave point
120     where it is if the headline is a valid target for refiling.
121     
122     If the target should not be selected, the function must return nil.
123     In addition to this, it may move point to a place from where the search
124     should be continued.  For example, the function may decide that the entire
125     subtree of the current entry should be excluded and move point to the end
126     of the subtree.
127 #+end_example
128 ** =org-after-todo-state-change-hook=
129 Defined in: /org.el/
130 #+begin_example
131     Hook which is run after the state of a TODO item was changed.
132     The new state (a string with a TODO keyword, or nil) is available in the
133     Lisp variable `state'.
134 #+end_example
135 ** =org-blocker-hook=
136 Defined in: /org.el/
137 #+begin_example
138     Hook for functions that are allowed to block a state change.
139     
140     Each function gets as its single argument a property list, see
141     `org-trigger-hook' for more information about this list.
142     
143     If any of the functions in this hook returns nil, the state change
144     is blocked.
145 #+end_example
146 ** =org-trigger-hook=
147 Defined in: /org.el/
148 #+begin_example
149     Hook for functions that are triggered by a state change.
150     
151     Each function gets as its single argument a property list with at least
152     the following elements:
153     
154      (:type type-of-change :position pos-at-entry-start
155       :from old-state :to new-state)
156     
157     Depending on the type, more properties may be present.
158     
159     This mechanism is currently implemented for:
160     
161     TODO state changes
162     ------------------
163     :type  todo-state-change
164     :from  previous state (keyword as a string), or nil, or a symbol
165            'todo' or 'done', to indicate the general type of state.
166     :to    new state, like in :from
167 #+end_example
168 ** =org-read-date-minibuffer-setup-hook=
169 Defined in: /org.el/
170 #+begin_example
171     Hook to be used to set up keys for the date/time interface.
172     Add key definitions to `minibuffer-local-map', which will be a temporary
173     copy.
174 #+end_example
175 ** =org-tags-sort-function=
176 Defined in: /org.el/
177 #+begin_example
178     When set, tags are sorted using this function as a comparator
179 #+end_example
180 ** =org-after-tags-change-hook=
181 Defined in: /org.el/
182 #+begin_example
183     Hook that is run after the tags in a line have changed.
184 #+end_example
185 ** =org-columns-modify-value-for-display-function=
186 Defined in: /org.el/
187 #+begin_example
188     Function that modifies values for display in column view.
189     For example, it can be used to cut out a certain part from a time stamp.
190     The function must take 2 arguments:
191     
192     column-title    The title of the column (*not* the property name)
193     value           The value that should be modified.
194     
195     The function should return the value that should be displayed,
196     or nil if the normal value should be used.
197 #+end_example
198 ** =org-finish-function=
199 Defined in: /org.el/
200 #+begin_example
201     Function to be called when `C-c C-c' is used.
202     This is for getting out of special buffers like remember.
203 #+end_example
204 ** =org-mode-hook=
205 Defined in: /org.el/
206 #+begin_example
207     Mode hook for Org-mode, run after the mode was turned on.
208 #+end_example
209 ** =org-font-lock-hook=
210 Defined in: /org.el/
211 #+begin_example
212     Functions to be called for special font lock stuff.
213 #+end_example
214 ** =org-after-demote-entry-hook=
215 Defined in: /org.el/
216 #+begin_example
217     Hook run after an entry has been demoted.
218     The cursor will be at the beginning of the entry.
219     When a subtree is being demoted, the hook will be called for each node.
220 #+end_example
221 ** =org-after-promote-entry-hook=
222 Defined in: /org.el/
223 #+begin_example
224     Hook run after an entry has been promoted.
225     The cursor will be at the beginning of the entry.
226     When a subtree is being promoted, the hook will be called for each node.
227 #+end_example
228 ** =org-after-sorting-entries-or-items-hook=
229 Defined in: /org.el/
230 #+begin_example
231     Hook that is run after a bunch of entries or items have been sorted.
232     When children are sorted, the cursor is in the parent line when this
233     hook gets called.  When a region or a plain list is sorted, the cursor
234     will be in the first entry of the sorted region/list.
235 #+end_example
236 ** =org-store-link-functions=
237 Defined in: /org.el/
238 #+begin_example
239     List of functions that are called to create and store a link.
240     Each function will be called in turn until one returns a non-nil
241     value.  Each function should check if it is responsible for creating
242     this link (for example by looking at the major mode).
243     If not, it must exit and return nil.
244     If yes, it should return a non-nil value after a calling
245     `org-store-link-props' with a list of properties and values.
246     Special properties are:
247     
248     :type         The link prefix. like \"http\".  This must be given.
249     :link         The link, like \"http://www.astro.uva.nl/~dominik\".
250                   This is obligatory as well.
251     :description  Optional default description for the second pair
252                   of brackets in an Org-mode link.  The user can still change
253                   this when inserting this link into an Org-mode buffer.
254     
255     In addition to these, any additional properties can be specified
256     and then used in remember templates.
257 #+end_example
258 ** =org-create-file-search-functions=
259 Defined in: /org.el/
260 #+begin_example
261     List of functions to construct the right search string for a file link.
262     These functions are called in turn with point at the location to
263     which the link should point.
264     
265     A function in the hook should first test if it would like to
266     handle this file type, for example by checking the major-mode or
267     the file extension.  If it decides not to handle this file, it
268     should just return nil to give other functions a chance.  If it
269     does handle the file, it must return the search string to be used
270     when following the link.  The search string will be part of the
271     file link, given after a double colon, and `org-open-at-point'
272     will automatically search for it.  If special measures must be
273     taken to make the search successful, another function should be
274     added to the companion hook `org-execute-file-search-functions',
275     which see.
276     
277     A function in this hook may also use `setq' to set the variable
278     `description' to provide a suggestion for the descriptive text to
279     be used for this link when it gets inserted into an Org-mode
280     buffer with \\[org-insert-link].
281 #+end_example
282 ** =org-execute-file-search-functions=
283 Defined in: /org.el/
284 #+begin_example
285     List of functions to execute a file search triggered by a link.
286     
287     Functions added to this hook must accept a single argument, the
288     search string that was part of the file link, the part after the
289     double colon.  The function must first check if it would like to
290     handle this search, for example by checking the major-mode or the
291     file extension.  If it decides not to handle this search, it
292     should just return nil to give other functions a chance.  If it
293     does handle the search, it must return a non-nil value to keep
294     other functions from trying.
295     
296     Each function can access the current prefix argument through the
297     variable `current-prefix-argument'.  Note that a single prefix is
298     used to force opening a link in Emacs, so it may be good to only
299     use a numeric or double prefix to guide the search function.
300     
301     In case this is needed, a function in this hook can also restore
302     the window configuration before `org-open-at-point' was called using:
303     
304         (set-window-configuration org-window-config-before-follow-link)
305 #+end_example
306 ** =org-after-refile-insert-hook=
307 Defined in: /org.el/
308 #+begin_example
309     Hook run after `org-refile' has inserted its stuff at the new location.
310     Note that this is still *before* the stuff will be removed from
311     the *old* location.
312 #+end_example
313 ** =org-todo-setup-filter-hook=
314 Defined in: /org.el/
315 #+begin_example
316     Hook for functions that pre-filter todo specs.
317     
318     Each function takes a todo spec and returns either `nil' or the spec
319     transformed into canonical form." )
320     
321     (defvar org-todo-get-default-hook nil
322       "Hook for functions that get a default item for todo.
323     
324     Each function takes arguments (NEW-MARK OLD-MARK) and returns either
325     `nil' or a string to be used for the todo mark." )
326     
327     (defvar org-agenda-headline-snapshot-before-repeat)
328     
329     (defun org-todo (&optional arg)
330       "Change the TODO state of an item.
331     The state of an item is given by a keyword at the start of the heading,
332     like
333          *** TODO Write paper
334          *** DONE Call mom
335     
336     The different keywords are specified in the variable `org-todo-keywords'.
337     By default the available states are \"TODO\" and \"DONE\".
338     So for this example: when the item starts with TODO, it is changed to DONE.
339     When it starts with DONE, the DONE is removed.  And when neither TODO nor
340     DONE are present, add TODO at the beginning of the heading.
341     
342     With C-u prefix arg, use completion to determine the new state.
343     With numeric prefix arg, switch to that state.
344     With a double C-u prefix, switch to the next set of TODO keywords (nextset).
345     With a tripple C-u prefix, circumvent any state blocking.
346     
347     For calling through lisp, arg is also interpreted in the following way:
348     'none             -> empty state
349     \"\"(empty string)  -> switch to empty state
350     'done             -> switch to DONE
351     'nextset          -> switch to the next set of keywords
352     'previousset      -> switch to the previous set of keywords
353     \"WAITING\"         -> switch to the specified keyword, but only if it
354                          really is a member of `org-todo-keywords'.
355 #+end_example
356 ** =org-after-todo-statistics-hook=
357 Defined in: /org.el/
358 #+begin_example
359     Hook that is called after a TODO statistics cookie has been updated.
360     Each function is called with two arguments: the number of not-done entries
361     and the number of done entries.
362     
363     For example, the following function, when added to this hook, will switch
364     an entry to DONE when all children are done, and back to TODO when new
365     entries are set to a TODO status.  Note that this hook is only called
366     when there is a statistics cookie in the headline!
367     
368      (defun org-summary-todo (n-done n-not-done)
369        \"Switch entry to DONE when all subentries are done, to TODO otherwise.\"
370        (let (org-log-done org-log-states)   ; turn off logging
371          (org-todo (if (= n-not-done 0) \"DONE\" \"TODO\"))))
372 #+end_example
373 ** =org-todo-statistics-hook=
374 Defined in: /org.el/
375 #+begin_example
376     Hook that is run whenever Org thinks TODO statistics should be updated.
377     This hook runs even if there is no statisics cookie present, in which case
378     `org-after-todo-statistics-hook' would not run.
379 #+end_example
380 ** =org-ctrl-c-ctrl-c-hook=
381 Defined in: /org.el/
382 #+begin_example
383     Hook for functions attaching themselves to  `C-c C-c'.
384     This can be used to add additional functionality to the C-c C-c key which
385     executes context-dependent commands.
386     Each function will be called with no arguments.  The function must check
387     if the context is appropriate for it to act.  If yes, it should do its
388     thing and then return a non-nil value.  If the context is wrong,
389     just do nothing and return nil.
390 #+end_example
391 ** =org-tab-first-hook=
392 Defined in: /org.el/
393 #+begin_example
394     Hook for functions to attach themselves to TAB.
395     See `org-ctrl-c-ctrl-c-hook' for more information.
396     This hook runs as the first action when TAB is pressed, even before
397     `org-cycle' messes around with the `outline-regexp' to cater for
398     inline tasks and plain list item folding.
399     If any function in this hook returns t, not other actions like table
400     field motion visibility cycling will be done.
401 #+end_example
402 ** =org-tab-after-check-for-table-hook=
403 Defined in: /org.el/
404 #+begin_example
405     Hook for functions to attach themselves to TAB.
406     See `org-ctrl-c-ctrl-c-hook' for more information.
407     This hook runs after it has been established that the cursor is not in a
408     table, but before checking if the cursor is in a headline or if global cycling
409     should be done.
410     If any function in this hook returns t, not other actions like visibility
411     cycling will be done.
412 #+end_example
413 ** =org-tab-after-check-for-cycling-hook=
414 Defined in: /org.el/
415 #+begin_example
416     Hook for functions to attach themselves to TAB.
417     See `org-ctrl-c-ctrl-c-hook' for more information.
418     This hook runs after it has been established that not table field motion and
419     not visibility should be done because of current context.  This is probably
420     the place where a package like yasnippets can hook in.
421 #+end_example
422 ** =org-metaleft-hook=
423 Defined in: /org.el/
424 #+begin_example
425     Hook for functions attaching themselves to `M-left'.
426     See `org-ctrl-c-ctrl-c-hook' for more information.
427 #+end_example
428 ** =org-metaright-hook=
429 Defined in: /org.el/
430 #+begin_example
431     Hook for functions attaching themselves to `M-right'.
432     See `org-ctrl-c-ctrl-c-hook' for more information.
433 #+end_example
434 ** =org-metaup-hook=
435 Defined in: /org.el/
436 #+begin_example
437     Hook for functions attaching themselves to `M-up'.
438     See `org-ctrl-c-ctrl-c-hook' for more information.
439 #+end_example
440 ** =org-metadown-hook=
441 Defined in: /org.el/
442 #+begin_example
443     Hook for functions attaching themselves to `M-down'.
444     See `org-ctrl-c-ctrl-c-hook' for more information.
445 #+end_example
446 ** =org-shiftmetaleft-hook=
447 Defined in: /org.el/
448 #+begin_example
449     Hook for functions attaching themselves to `M-S-left'.
450     See `org-ctrl-c-ctrl-c-hook' for more information.
451 #+end_example
452 ** =org-shiftmetaright-hook=
453 Defined in: /org.el/
454 #+begin_example
455     Hook for functions attaching themselves to `M-S-right'.
456     See `org-ctrl-c-ctrl-c-hook' for more information.
457 #+end_example
458 ** =org-shiftmetaup-hook=
459 Defined in: /org.el/
460 #+begin_example
461     Hook for functions attaching themselves to `M-S-up'.
462     See `org-ctrl-c-ctrl-c-hook' for more information.
463 #+end_example
464 ** =org-shiftmetadown-hook=
465 Defined in: /org.el/
466 #+begin_example
467     Hook for functions attaching themselves to `M-S-down'.
468     See `org-ctrl-c-ctrl-c-hook' for more information.
469 #+end_example
470 ** =org-metareturn-hook=
471 Defined in: /org.el/
472 #+begin_example
473     Hook for functions attaching themselves to `M-RET'.
474     See `org-ctrl-c-ctrl-c-hook' for more information.
475 #+end_example
476 ** =org-agenda-before-write-hook=
477 Defined in: /org-agenda.el/
478 #+begin_example
479     Hook run in temporary buffer before writing it to an export file.
480     A useful function is `org-agenda-add-entry-text'.
481 #+end_example
482 ** =org-finalize-agenda-hook=
483 Defined in: /org-agenda.el/
484 #+begin_example
485     Hook run just before displaying an agenda buffer.
486 #+end_example
487 ** =org-agenda-mode-hook=
488 Defined in: /org-agenda.el/
489 #+begin_example
490     Hook for org-agenda-mode, run after the mode is turned on.
491 #+end_example
492 ** =org-agenda-skip-function=
493 Defined in: /org-agenda.el/
494 #+begin_example
495     Function to be called at each match during agenda construction.
496     If this function returns nil, the current match should not be skipped.
497     Otherwise, the function must return a position from where the search
498     should be continued.
499     This may also be a Lisp form, it will be evaluated.
500     Never set this variable using `setq' or so, because then it will apply
501     to all future agenda commands.  Instead, bind it with `let' to scope
502     it dynamically into the agenda-constructing command.  A good way to set
503     it is through options in org-agenda-custom-commands.
504 #+end_example
505 ** =org-agenda-cleanup-fancy-diary-hook=
506 Defined in: /org-agenda.el/
507 #+begin_example
508     Hook run when the fancy diary buffer is cleaned up.
509 #+end_example
510 ** =org-agenda-after-show-hook=
511 Defined in: /org-agenda.el/
512 #+begin_example
513     Normal hook run after an item has been shown from the agenda.
514     Point is in the buffer where the item originated.
515 #+end_example
516 ** =org-clock-heading-function=
517 Defined in: /org-clock.el/
518 #+begin_example
519     When non-nil, should be a function to create `org-clock-heading'.
520     This is the string shown in the mode line when a clock is running.
521     The function is called with point at the beginning of the headline.
522 #+end_example
523 ** =org-clock-in-prepare-hook=
524 Defined in: /org-clock.el/
525 #+begin_example
526     Hook run when preparing the clock.
527     This hook is run before anything happens to the task that
528     you want to clock in.  For example, you can use this hook
529     to add an effort property.
530 #+end_example
531 ** =org-clock-in-hook=
532 Defined in: /org-clock.el/
533 #+begin_example
534     Hook run when starting the clock.
535 #+end_example
536 ** =org-clock-out-hook=
537 Defined in: /org-clock.el/
538 #+begin_example
539     Hook run when stopping the current clock.
540 #+end_example
541 ** =org-clock-cancel-hook=
542 Defined in: /org-clock.el/
543 #+begin_example
544     Hook run when cancelling the current clock.
545 #+end_example
546 ** =org-clock-goto-hook=
547 Defined in: /org-clock.el/
548 #+begin_example
549     Hook run when selecting the currently clocked-in entry.
550 #+end_example
551 ** =org-export-preprocess-hook=
552 Defined in: /org-exp.el/
553 #+begin_example
554     Hook for preprocessing an export buffer.
555     Pretty much the first thing when exporting is running this hook.
556 #+end_example
557 ** =org-export-preprocess-after-include-files-hook=
558 Defined in: /org-exp.el/
559 #+begin_example
560     Hook for preprocessing an export buffer.
561     This is run after the contents of included files have been inserted.
562 #+end_example
563 ** =org-export-preprocess-after-tree-selection-hook=
564 Defined in: /org-exp.el/
565 #+begin_example
566     Hook for preprocessing an export buffer.
567     This is run after selection of trees to be exported has happened.
568     This selection includes tags-based selection, as well as removal
569     of commented and archived trees.
570 #+end_example
571 ** =org-export-preprocess-after-blockquote-hook=
572 Defined in: /org-exp.el/
573 #+begin_example
574     Hook for preprocessing an export buffer.
575     This is run after blockquote/quote/verse/center have been marked
576     with cookies.
577 #+end_example
578 ** =org-export-preprocess-before-backend-specifics-hook=
579 Defined in: /org-exp.el/
580 #+begin_example
581     Hook run before backend-specific functions are called during preprocessing.
582 #+end_example
583 ** =org-export-preprocess-final-hook=
584 Defined in: /org-exp.el/
585 #+begin_example
586     Hook for preprocessing an export buffer.
587     This is run as the last thing in the preprocessing buffer, just before
588     returning the buffer string to the backend.
589 #+end_example
590 ** =org-feed-after-adding-hook=
591 Defined in: /org-feed.el/
592 #+begin_example
593     Hook that is run after new items have been added to a file.
594     Depending on `org-feed-save-after-adding', the buffer will already
595     have been saved.
596 #+end_example
597 ** =org-export-html-after-blockquotes-hook=
598 Defined in: /org-html.el/
599 #+begin_example
600     Hook run during HTML export, after blockquote, verse, center are done.
601 #+end_example
602 ** =org-before-save-iCalendar-file-hook=
603 Defined in: /org-icalendar.el/
604 #+begin_example
605     Hook run before  an iCalendar file has been saved.
606     This can be used to modify the result of the export.
607 #+end_example
608 ** =org-after-save-iCalendar-file-hook=
609 Defined in: /org-icalendar.el/
610 #+begin_example
611     Hook run after an iCalendar file has been saved.
612     The iCalendar buffer is still current when this hook is run.
613     A good way to use this is to tell a desktop calendar application to re-read
614     the iCalendar file.
615 #+end_example
616 ** =org-export-latex-after-blockquotes-hook=
617 Defined in: /org-latex.el/
618 #+begin_example
619     Hook run during LaTeX export, after blockquote, verse, center are done.
620 #+end_example
621 ** =org-checkbox-statistics-hook=
622 Defined in: /org-list.el/
623 #+begin_example
624     Hook that is run whenever Org thinks checkbox statistics should be updated.
625     This hook runs even if `org-provide-checkbox-statistics' is nil, to it can
626     be used to implement alternative ways of collecting statistics information.
627 #+end_example
628 ** =org-mouse-context-menu-function=
629 Defined in: /org-mouse.el/
630 #+begin_example
631     Function to create the context menu.
632     The value of this variable is the function invoked by
633     `org-mouse-context-menu' as the context menu.
634 #+end_example
635 ** =org-publish-before-export-hook=
636 Defined in: /org-publish.el/
637 #+begin_example
638     Hook run before export on the Org file.
639     The hook may modify the file in arbitrary ways before publishing happens.
640     The orgiginal version of the buffer will be restored after publishing.
641 #+end_example
642 ** =org-publish-after-export-hook=
643 Defined in: /org-publish.el/
644 #+begin_example
645     Hook run after export on the exported buffer.
646     Any changes made by this hook will be saved.
647 #+end_example
648 ** =org-remember-before-finalize-hook=
649 Defined in: /org-remember.el/
650 #+begin_example
651     Hook that is run right before a remember process is finalized.
652     The remember buffer is still current when this hook runs.
653 #+end_example
654 ** =org-remember-mode-hook=
655 Defined in: /org-remember.el/
656 #+begin_example
657     Hook for the minor `org-remember-mode'.
658 #+end_example
659 ** =org-src-mode-hook=
660 Defined in: /org-src.el/
661 #+begin_example
662     Hook  run after Org switched a source code snippet to its Emacs mode.
663     This hook will run
664     
665     - when editing a source code snippet with \"C-c '\".
666     - When formatting a source code snippet for export with htmlize.
667     
668     You may want to use this hook for example to turn off `outline-minor-mode'
669     or similar things which you want to have when editing a source code file,
670     but which mess up the display of a snippet in Org exported files.
671 #+end_example
674 * Examples for using hooks
676 Feel free to give example of how do you use these hooks.  Ideas for
677 other hooks are also welcome.
679 ** org-follow-link-hook                                                 :bzg:
681 If  you want to display dormant article when following Gnus articles:
683 #+BEGIN_SRC emacs-lisp
684 (add-hook 'org-follow-link-hook 
685           (lambda () (if (eq major-mode 'gnus-summary-mode)
686                          (gnus-summary-insert-dormant-articles))))
687 #+END_SRC
689 ** org-agenda-after-show-hook
691 To get a compact view during follow mode in the agenda, you could try
692 this:
694 #+begin_src emacs-lisp
695   (defun my-compact-follow ()
696     "Make the view compact, then show the necessary minimum."
697     (ignore-errors
698       (save-excursion
699         (while (org-up-heading-safe))
700         (hide-subtree)))
701     (let ((org-show-siblings nil)
702           (org-show-hierarchy-above t))
703       (org-reveal))
704     (save-excursion
705       (org-back-to-heading t)
706       (show-children)))
707   
708   (add-hook 'org-agenda-after-show-hook 'my-compact-follow)
709 #+end_src
711 # org-add-hook?