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
6 #+EMAIL: bzg AT altern DOT org
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
24 Mode hook for Org-mode, run after the mode was turned on.
29 Hook that is run after org.el has been loaded.
31 ** =org-pre-cycle-hook=
34 Hook that is run before visibility cycling is happening.
35 The function(s) in this hook must accept a single argument which indicates
36 the new state that will be set right after running this hook. The
37 argument is a symbol. Before a global state change, it can have the values
38 `overview', `content', or `all'. Before a local state change, it can have
39 the values `folded', `children', or `subtree'.
44 Hook that is run after `org-cycle' has changed the buffer visibility.
45 The function(s) in this hook must accept a single argument which indicates
46 the new state that was set by the most recent `org-cycle' command. The
47 argument is a symbol. After a global state change, it can have the values
48 `overview', `content', or `all'. After a local state change, it can have
49 the values `folded', `children', or `subtree'.
51 ** =org-insert-heading-hook=
54 Hook being run after inserting a new heading.
59 Hook that is run after `org-occur' has constructed a sparse tree.
60 This can be used to recenter the window to show as much of the structure
63 ** =org-make-link-description-function=
66 Function to use to generate link descriptions from links. If
67 nil the link location will be used. This function must take two
68 parameters; the first is the link and the second the description
69 org-insert-link has generated, and should return the description
72 ** =org-link-translation-function=
75 Function to translate links with different syntax to Org syntax.
76 This can be used to translate links created for example by the Planner
77 or emacs-wiki packages to Org syntax.
78 The function must accept two parameters, a TYPE containing the link
79 protocol name like \"rmail\" or \"gnus\" as a string, and the linked path,
80 which is everything after the link protocol. It should return a cons
81 with possibly modified values of type and path.
82 Org contains a function for this, so if you set this variable to
83 `org-translate-link-from-planner', you should be able follow many
84 links created by planner.
86 ** =org-follow-link-hook=
89 Hook that is run after a link has been followed.
91 ** =org-confirm-shell-link-function=
94 Non-nil means ask for confirmation before executing shell links.
95 Shell links can be dangerous: just think about a link
97 [[shell:rm -rf ~/*][Google Search]]
99 This link would show up in your Org-mode document as \"Google Search\",
100 but really it would remove your entire home directory.
101 Therefore we advise against setting this variable to nil.
102 Just change it to `y-or-n-p' if you want to confirm with a
103 single keystroke rather than having to type \"yes\".
105 ** =org-confirm-elisp-link-function=
108 Non-nil means ask for confirmation before executing Emacs Lisp links.
109 Elisp links can be dangerous: just think about a link
111 [[elisp:(shell-command \"rm -rf ~/*\")][Google Search]]
113 This link would show up in your Org-mode document as \"Google Search\",
114 but really it would remove your entire home directory.
115 Therefore we advise against setting this variable to nil.
116 Just change it to `y-or-n-p' if you want to confirm with a
117 single keystroke rather than having to type \"yes\".
119 ** =org-refile-target-verify-function=
122 Function to verify if the headline at point should be a refile target.
123 The function will be called without arguments, with point at the
124 beginning of the headline. It should return t and leave point
125 where it is if the headline is a valid target for refiling.
127 If the target should not be selected, the function must return nil.
128 In addition to this, it may move point to a place from where the search
129 should be continued. For example, the function may decide that the entire
130 subtree of the current entry should be excluded and move point to the end
133 ** =org-after-todo-state-change-hook=
136 Hook which is run after the state of a TODO item was changed.
137 The new state (a string with a TODO keyword, or nil) is available in the
138 Lisp variable `state'.
140 ** =org-blocker-hook=
143 Hook for functions that are allowed to block a state change.
145 Each function gets as its single argument a property list, see
146 `org-trigger-hook' for more information about this list.
148 If any of the functions in this hook returns nil, the state change
151 ** =org-trigger-hook=
154 Hook for functions that are triggered by a state change.
156 Each function gets as its single argument a property list with at least
157 the following elements:
159 (:type type-of-change :position pos-at-entry-start
160 :from old-state :to new-state)
162 Depending on the type, more properties may be present.
164 This mechanism is currently implemented for:
168 :type todo-state-change
169 :from previous state (keyword as a string), or nil, or a symbol
170 'todo' or 'done', to indicate the general type of state.
171 :to new state, like in :from
173 ** =org-read-date-minibuffer-setup-hook=
176 Hook to be used to set up keys for the date/time interface.
177 Add key definitions to `minibuffer-local-map', which will be a temporary
180 ** =org-tags-sort-function=
183 When set, tags are sorted using this function as a comparator
185 ** =org-after-tags-change-hook=
188 Hook that is run after the tags in a line have changed.
190 ** =org-columns-modify-value-for-display-function=
193 Function that modifies values for display in column view.
194 For example, it can be used to cut out a certain part from a time stamp.
195 The function must take 2 arguments:
197 column-title The title of the column (*not* the property name)
198 value The value that should be modified.
200 The function should return the value that should be displayed,
201 or nil if the normal value should be used.
203 ** =org-finish-function=
206 Function to be called when `C-c C-c' is used.
207 This is for getting out of special buffers like remember.
209 ** =org-font-lock-hook=
212 Functions to be called for special font lock stuff.
214 ** =org-after-demote-entry-hook=
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.
221 ** =org-after-promote-entry-hook=
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.
228 ** =org-after-sorting-entries-or-items-hook=
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.
236 ** =org-store-link-functions=
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:
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.
255 In addition to these, any additional properties can be specified
256 and then used in remember templates.
258 ** =org-open-link-functions=
261 Hook for functions finding a plain text link.
262 These functions must take a single argument, the link content.
263 They will be called for links that look like [[link text][description]]
264 when LINK TEXT does not have a protocol like \"http:\" and does not look
265 like a filename (e.g. \"./blue.png\").
267 These functions will be called *before* Org attempts to resolve the
268 link by doing text searches in the current buffer - so if you want a
269 link \"[[target]]\" to still find \"<<target>>\", your function should
270 handle this as a special case.
272 When the function does handle the link, it must return a non-nil value.
273 If it decides that it is not responsible for this link, it must return
274 nil to indicate that that Org-mode can continue with other options
275 like exact and fuzzy text search.
277 ** =org-create-file-search-functions=
280 List of functions to construct the right search string for a file link.
281 These functions are called in turn with point at the location to
282 which the link should point.
284 A function in the hook should first test if it would like to
285 handle this file type, for example by checking the major-mode or
286 the file extension. If it decides not to handle this file, it
287 should just return nil to give other functions a chance. If it
288 does handle the file, it must return the search string to be used
289 when following the link. The search string will be part of the
290 file link, given after a double colon, and `org-open-at-point'
291 will automatically search for it. If special measures must be
292 taken to make the search successful, another function should be
293 added to the companion hook `org-execute-file-search-functions',
296 A function in this hook may also use `setq' to set the variable
297 `description' to provide a suggestion for the descriptive text to
298 be used for this link when it gets inserted into an Org-mode
299 buffer with \\[org-insert-link].
301 ** =org-execute-file-search-functions=
304 List of functions to execute a file search triggered by a link.
306 Functions added to this hook must accept a single argument, the
307 search string that was part of the file link, the part after the
308 double colon. The function must first check if it would like to
309 handle this search, for example by checking the major-mode or the
310 file extension. If it decides not to handle this search, it
311 should just return nil to give other functions a chance. If it
312 does handle the search, it must return a non-nil value to keep
313 other functions from trying.
315 Each function can access the current prefix argument through the
316 variable `current-prefix-argument'. Note that a single prefix is
317 used to force opening a link in Emacs, so it may be good to only
318 use a numeric or double prefix to guide the search function.
320 In case this is needed, a function in this hook can also restore
321 the window configuration before `org-open-at-point' was called using:
323 (set-window-configuration org-window-config-before-follow-link)
325 ** =org-after-refile-insert-hook=
328 Hook run after `org-refile' has inserted its stuff at the new location.
329 Note that this is still *before* the stuff will be removed from
332 ** =org-todo-setup-filter-hook=
335 Hook for functions that pre-filter todo specs.
337 Each function takes a todo spec and returns either `nil' or the spec
338 transformed into canonical form." )
340 (defvar org-todo-get-default-hook nil
341 "Hook for functions that get a default item for todo.
343 Each function takes arguments (NEW-MARK OLD-MARK) and returns either
344 `nil' or a string to be used for the todo mark." )
346 (defvar org-agenda-headline-snapshot-before-repeat)
348 (defun org-todo (&optional arg)
349 "Change the TODO state of an item.
350 The state of an item is given by a keyword at the start of the heading,
355 The different keywords are specified in the variable `org-todo-keywords'.
356 By default the available states are \"TODO\" and \"DONE\".
357 So for this example: when the item starts with TODO, it is changed to DONE.
358 When it starts with DONE, the DONE is removed. And when neither TODO nor
359 DONE are present, add TODO at the beginning of the heading.
361 With C-u prefix arg, use completion to determine the new state.
362 With numeric prefix arg, switch to that state.
363 With a double C-u prefix, switch to the next set of TODO keywords (nextset).
364 With a triple C-u prefix, circumvent any state blocking.
366 For calling through lisp, arg is also interpreted in the following way:
368 \"\"(empty string) -> switch to empty state
369 'done -> switch to DONE
370 'nextset -> switch to the next set of keywords
371 'previousset -> switch to the previous set of keywords
372 \"WAITING\" -> switch to the specified keyword, but only if it
373 really is a member of `org-todo-keywords'.
375 ** =org-after-todo-statistics-hook=
378 Hook that is called after a TODO statistics cookie has been updated.
379 Each function is called with two arguments: the number of not-done entries
380 and the number of done entries.
382 For example, the following function, when added to this hook, will switch
383 an entry to DONE when all children are done, and back to TODO when new
384 entries are set to a TODO status. Note that this hook is only called
385 when there is a statistics cookie in the headline!
387 (defun org-summary-todo (n-done n-not-done)
388 \"Switch entry to DONE when all subentries are done, to TODO otherwise.\"
389 (let (org-log-done org-log-states) ; turn off logging
390 (org-todo (if (= n-not-done 0) \"DONE\" \"TODO\"))))
392 ** =org-todo-statistics-hook=
395 Hook that is run whenever Org thinks TODO statistics should be updated.
396 This hook runs even if there is no statistics cookie present, in which case
397 `org-after-todo-statistics-hook' would not run.
399 ** =org-reveal-start-hook=
402 Hook run before revealing a location.
404 ** =org-property-changed-functions=
407 Hook called when the value of a property has changed.
408 Each hook function should accept two arguments, the name of the property
411 ** =org-property-allowed-value-functions=
414 Hook for functions supplying allowed values for a specific property.
415 The functions must take a single argument, the name of the property, and
416 return a flat list of allowed values. If \":ETC\" is one of
417 the values, this means that these values are intended as defaults for
418 completion, but that other values should be allowed too.
419 The functions must return nil if they are not responsible for this
422 ** =org-ctrl-c-ctrl-c-hook=
425 Hook for functions attaching themselves to `C-c C-c'.
426 This can be used to add additional functionality to the C-c C-c key which
427 executes context-dependent commands.
428 Each function will be called with no arguments. The function must check
429 if the context is appropriate for it to act. If yes, it should do its
430 thing and then return a non-nil value. If the context is wrong,
431 just do nothing and return nil.
433 ** =org-tab-first-hook=
436 Hook for functions to attach themselves to TAB.
437 See `org-ctrl-c-ctrl-c-hook' for more information.
438 This hook runs as the first action when TAB is pressed, even before
439 `org-cycle' messes around with the `outline-regexp' to cater for
440 inline tasks and plain list item folding.
441 If any function in this hook returns t, not other actions like table
442 field motion visibility cycling will be done.
444 ** =org-tab-after-check-for-table-hook=
447 Hook for functions to attach themselves to TAB.
448 See `org-ctrl-c-ctrl-c-hook' for more information.
449 This hook runs after it has been established that the cursor is not in a
450 table, but before checking if the cursor is in a headline or if global cycling
452 If any function in this hook returns t, not other actions like visibility
453 cycling will be done.
455 ** =org-tab-after-check-for-cycling-hook=
458 Hook for functions to attach themselves to TAB.
459 See `org-ctrl-c-ctrl-c-hook' for more information.
460 This hook runs after it has been established that not table field motion and
461 not visibility should be done because of current context. This is probably
462 the place where a package like yasnippets can hook in.
464 ** =org-tab-before-tab-emulation-hook=
467 Hook for functions to attach themselves to TAB.
468 See `org-ctrl-c-ctrl-c-hook' for more information.
469 This hook runs after every other options for TAB have been exhausted, but
470 before indentation and \t insertion takes place.
472 ** =org-metaleft-hook=
475 Hook for functions attaching themselves to `M-left'.
476 See `org-ctrl-c-ctrl-c-hook' for more information.
478 ** =org-metaright-hook=
481 Hook for functions attaching themselves to `M-right'.
482 See `org-ctrl-c-ctrl-c-hook' for more information.
487 Hook for functions attaching themselves to `M-up'.
488 See `org-ctrl-c-ctrl-c-hook' for more information.
490 ** =org-metadown-hook=
493 Hook for functions attaching themselves to `M-down'.
494 See `org-ctrl-c-ctrl-c-hook' for more information.
496 ** =org-shiftmetaleft-hook=
499 Hook for functions attaching themselves to `M-S-left'.
500 See `org-ctrl-c-ctrl-c-hook' for more information.
502 ** =org-shiftmetaright-hook=
505 Hook for functions attaching themselves to `M-S-right'.
506 See `org-ctrl-c-ctrl-c-hook' for more information.
508 ** =org-shiftmetaup-hook=
511 Hook for functions attaching themselves to `M-S-up'.
512 See `org-ctrl-c-ctrl-c-hook' for more information.
514 ** =org-shiftmetadown-hook=
517 Hook for functions attaching themselves to `M-S-down'.
518 See `org-ctrl-c-ctrl-c-hook' for more information.
520 ** =org-metareturn-hook=
523 Hook for functions attaching themselves to `M-RET'.
524 See `org-ctrl-c-ctrl-c-hook' for more information.
526 ** =org-shiftup-hook=
529 Hook for functions attaching themselves to `S-up'.
530 See `org-ctrl-c-ctrl-c-hook' for more information.
532 ** =org-shiftup-final-hook=
535 Hook for functions attaching themselves to `S-up'.
536 This one runs after all other options except shift-select have been excluded.
537 See `org-ctrl-c-ctrl-c-hook' for more information.
539 ** =org-shiftdown-hook=
542 Hook for functions attaching themselves to `S-down'.
543 See `org-ctrl-c-ctrl-c-hook' for more information.
545 ** =org-shiftdown-final-hook=
548 Hook for functions attaching themselves to `S-down'.
549 This one runs after all other options except shift-select have been excluded.
550 See `org-ctrl-c-ctrl-c-hook' for more information.
552 ** =org-shiftleft-hook=
555 Hook for functions attaching themselves to `S-left'.
556 See `org-ctrl-c-ctrl-c-hook' for more information.
558 ** =org-shiftleft-final-hook=
561 Hook for functions attaching themselves to `S-left'.
562 This one runs after all other options except shift-select have been excluded.
563 See `org-ctrl-c-ctrl-c-hook' for more information.
565 ** =org-shiftright-hook=
568 Hook for functions attaching themselves to `S-right'.
569 See `org-ctrl-c-ctrl-c-hook' for more information.
571 ** =org-shiftright-final-hook=
574 Hook for functions attaching themselves to `S-right'.
575 This one runs after all other options except shift-select have been excluded.
576 See `org-ctrl-c-ctrl-c-hook' for more information.
578 ** =org-agenda-before-write-hook=
579 Defined in: /org-agenda.el/
581 Hook run in temporary buffer before writing it to an export file.
582 A useful function is `org-agenda-add-entry-text'.
584 ** =org-finalize-agenda-hook=
585 Defined in: /org-agenda.el/
587 Hook run just before displaying an agenda buffer.
589 ** =org-agenda-entry-text-cleanup-hook=
590 Defined in: /org-agenda.el/
592 Hook that is run after basic cleanup of entry text to be shown in agenda.
593 This cleanup is done in a temporary buffer, so the function may inspect and
594 change the entire buffer.
595 Some default stuff like drawers and scheduling/deadline dates will already
596 have been removed when this is called, as will any matches for regular
597 expressions listed in `org-agenda-entry-text-exclude-regexps'.
599 ** =org-agenda-auto-exclude-function=
600 Defined in: /org-agenda.el/
602 A function called with a tag to decide if it is filtered on '/ RET'.
603 The sole argument to the function, which is called once for each
604 possible tag, is a string giving the name of the tag. The
605 function should return either nil if the tag should be included
606 as normal, or \"-<TAG>\" to exclude the tag.
607 Note that for the purpose of tag filtering, only the lower-case version of
608 all tags will be considered, so that this function will only ever see
609 the lower-case version of all tags.
611 ** =org-agenda-mode-hook=
612 Defined in: /org-agenda.el/
614 Hook for org-agenda-mode, run after the mode is turned on.
616 ** =org-agenda-skip-function=
617 Defined in: /org-agenda.el/
619 Function to be called at each match during agenda construction.
620 If this function returns nil, the current match should not be skipped.
621 Otherwise, the function must return a position from where the search
623 This may also be a Lisp form, it will be evaluated.
624 Never set this variable using `setq' or so, because then it will apply
625 to all future agenda commands. Instead, bind it with `let' to scope
626 it dynamically into the agenda-constructing command. A good way to set
627 it is through options in org-agenda-custom-commands.
629 ** =org-agenda-cleanup-fancy-diary-hook=
630 Defined in: /org-agenda.el/
632 Hook run when the fancy diary buffer is cleaned up.
634 ** =org-agenda-after-show-hook=
635 Defined in: /org-agenda.el/
637 Normal hook run after an item has been shown from the agenda.
638 Point is in the buffer where the item originated.
640 ** =org-export-ascii-final-hook=
641 Defined in: /org-ascii.el/
643 Hook run at the end of ASCII export, in the new buffer.
645 ** =org-clock-heading-function=
646 Defined in: /org-clock.el/
648 When non-nil, should be a function to create `org-clock-heading'.
649 This is the string shown in the mode line when a clock is running.
650 The function is called with point at the beginning of the headline.
652 ** =org-clock-in-prepare-hook=
653 Defined in: /org-clock.el/
655 Hook run when preparing the clock.
656 This hook is run before anything happens to the task that
657 you want to clock in. For example, you can use this hook
658 to add an effort property.
660 ** =org-clock-in-hook=
661 Defined in: /org-clock.el/
663 Hook run when starting the clock.
665 ** =org-clock-out-hook=
666 Defined in: /org-clock.el/
668 Hook run when stopping the current clock.
670 ** =org-clock-cancel-hook=
671 Defined in: /org-clock.el/
673 Hook run when cancelling the current clock.
675 ** =org-clock-goto-hook=
676 Defined in: /org-clock.el/
678 Hook run when selecting the currently clocked-in entry.
680 ** =org-ctags-open-link-functions=
681 Defined in: /org-ctags.el/
683 List of functions to be prepended to ORG-OPEN-LINK-FUNCTIONS when
686 ** =org-export-docbook-final-hook=
687 Defined in: /org-docbook.el/
689 Hook run at the end of DocBook export, in the new buffer.
691 ** =org-export-first-hook=
692 Defined in: /org-exp.el/
694 Hook called as the first thing in each exporter.
695 Point will be still in the original buffer.
696 Good for general initialization
698 ** =org-export-preprocess-hook=
699 Defined in: /org-exp.el/
701 Hook for preprocessing an export buffer.
702 Pretty much the first thing when exporting is running this hook.
703 Point will be in a temporary buffer that contains a copy of
704 the original buffer, or of the section that is being export.
705 All the other hooks in the org-export-preprocess... category
706 also work in that temporary buffer, already modified by various
707 stages of the processing.
709 ** =org-export-preprocess-after-include-files-hook=
710 Defined in: /org-exp.el/
712 Hook for preprocessing an export buffer.
713 This is run after the contents of included files have been inserted.
715 ** =org-export-preprocess-after-tree-selection-hook=
716 Defined in: /org-exp.el/
718 Hook for preprocessing an export buffer.
719 This is run after selection of trees to be exported has happened.
720 This selection includes tags-based selection, as well as removal
721 of commented and archived trees.
723 ** =org-export-preprocess-after-headline-targets-hook=
724 Defined in: /org-exp.el/
726 Hook for preprocessing export buffer.
727 This is run just after the headline targets have been defined and
728 the target-alist has been set up.
730 ** =org-export-preprocess-before-selecting-backend-code-hook=
731 Defined in: /org-exp.el/
733 Hook for preprocessing an export buffer.
734 This is run just before backend-specific blocks get selected.
736 ** =org-export-preprocess-after-blockquote-hook=
737 Defined in: /org-exp.el/
739 Hook for preprocessing an export buffer.
740 This is run after blockquote/quote/verse/center have been marked
743 ** =org-export-preprocess-before-normalizing-links-hook=
744 Defined in: /org-exp.el/
746 Hook for preprocessing an export buffer.
747 This hook is run before links are normalized.
749 ** =org-export-preprocess-before-backend-specifics-hook=
750 Defined in: /org-exp.el/
752 Hook run before backend-specific functions are called during preprocessing.
754 ** =org-export-preprocess-final-hook=
755 Defined in: /org-exp.el/
757 Hook for preprocessing an export buffer.
758 This is run as the last thing in the preprocessing buffer, just before
759 returning the buffer string to the backend.
761 ** =org-export-format-drawer-function=
762 Defined in: /org-exp.el/
764 Function to be called to format the contents of a drawer.
765 The function must accept three parameters:
766 NAME the drawer name, like \"PROPERTIES\"
767 CONTENT the content of the drawer.
768 BACKEND one of the symbols html, docbook, latex, ascii, xoxo
769 The function should return the text to be inserted into the buffer.
770 If this is nil, `org-export-format-drawer' is used as a default.
772 ** =org-feed-after-adding-hook=
773 Defined in: /org-feed.el/
775 Hook that is run after new items have been added to a file.
776 Depending on `org-feed-save-after-adding', the buffer will already
779 ** =org-export-html-after-blockquotes-hook=
780 Defined in: /org-html.el/
782 Hook run during HTML export, after blockquote, verse, center are done.
784 ** =org-export-html-final-hook=
785 Defined in: /org-html.el/
787 Hook run at the end of HTML export, in the new buffer.
789 ** =org-icalendar-verify-function=
790 Defined in: /org-icalendar.el/
792 Function to verify entries for iCalendar export.
793 This can be set to a function that will be called at each entry that
794 is considered for export to iCalendar. When the function returns nil,
795 the entry will be skipped. When it returns a non-nil value, the entry
796 will be considered for export.
797 This is used internally when an agenda buffer is exported to an ics file,
798 to make sure that only entries currently listed in the agenda will end
799 up in the ics file. But for normal iCalendar export, you can use this
800 for whatever you need.
802 ** =org-before-save-iCalendar-file-hook=
803 Defined in: /org-icalendar.el/
805 Hook run before an iCalendar file has been saved.
806 This can be used to modify the result of the export.
808 ** =org-after-save-iCalendar-file-hook=
809 Defined in: /org-icalendar.el/
811 Hook run after an iCalendar file has been saved.
812 The iCalendar buffer is still current when this hook is run.
813 A good way to use this is to tell a desktop calendar application to re-read
816 ** =org-export-latex-after-initial-vars-hook=
817 Defined in: /org-latex.el/
819 Hook run before LaTeX export.
820 The exact moment is after the initial variables like org-export-latex-class
821 have been determined from the environment.
823 ** =org-export-latex-after-blockquotes-hook=
824 Defined in: /org-latex.el/
826 Hook run during LaTeX export, after blockquote, verse, center are done.
828 ** =org-export-latex-final-hook=
829 Defined in: /org-latex.el/
831 Hook run in the finalized LaTeX buffer.
833 ** =org-export-latex-after-save-hook=
834 Defined in: /org-latex.el/
836 Hook run in the finalized LaTeX buffer, after it has been saved.
838 ** =org-export-latex-format-toc-function=
839 Defined in: /org-latex.el/
841 The function formatting returning the string to createthe table of contents.
842 The function mus take one parameter, the depth of the table of contents.
844 ** =org-checkbox-statistics-hook=
845 Defined in: /org-list.el/
847 Hook that is run whenever Org thinks checkbox statistics should be updated.
848 This hook runs even if `org-provide-checkbox-statistics' is nil, to it can
849 be used to implement alternative ways of collecting statistics information.
851 ** =org-mobile-pre-push-hook=
852 Defined in: /org-mobile.el/
854 Hook run before running `org-mobile-push'.
855 This could be used to clean up `org-mobile-directory', for example to
856 remove files that used to be included in the agenda but no longer are.
857 The presence of such files would not really be a problem, but after time
860 ** =org-mobile-post-push-hook=
861 Defined in: /org-mobile.el/
863 Hook run after running `org-mobile-push'.
864 If Emacs does not have direct write access to the WebDAV directory used
865 by the mobile device, this hook should be used to copy all files from the
866 local staging directory `org-mobile-directory' to the WebDAV directory,
867 for example using `rsync' or `scp'.
869 ** =org-mobile-pre-pull-hook=
870 Defined in: /org-mobile.el/
872 Hook run before executing `org-mobile-pull'.
873 If Emacs does not have direct write access to the WebDAV directory used
874 by the mobile device, this hook should be used to copy the capture file
875 `mobileorg.org' from the WebDAV location to the local staging
876 directory `org-mobile-directory'.
878 ** =org-mobile-post-pull-hook=
879 Defined in: /org-mobile.el/
881 Hook run after running `org-mobile-pull'.
882 If Emacs does not have direct write access to the WebDAV directory used
883 by the mobile device, this hook should be used to copy the emptied
884 capture file `mobileorg.org' back to the WebDAV directory, for example
885 using `rsync' or `scp'.
887 ** =org-mobile-before-process-capture-hook=
888 Defined in: /org-mobile.el/
890 Hook that is run after content was moved to `org-mobile-inbox-for-pull'.
891 The inbox file is visited by the current buffer, and the buffer is
892 narrowed to the newly captured data.
894 ** =org-mouse-context-menu-function=
895 Defined in: /org-mouse.el/
897 Function to create the context menu.
898 The value of this variable is the function invoked by
899 `org-mouse-context-menu' as the context menu.
901 ** =org-publish-before-export-hook=
902 Defined in: /org-publish.el/
904 Hook run before export on the Org file.
905 The hook may modify the file in arbitrary ways before publishing happens.
906 The original version of the buffer will be restored after publishing.
908 ** =org-publish-after-export-hook=
909 Defined in: /org-publish.el/
911 Hook run after export on the exported buffer.
912 Any changes made by this hook will be saved.
914 ** =org-remember-before-finalize-hook=
915 Defined in: /org-remember.el/
917 Hook that is run right before a remember process is finalized.
918 The remember buffer is still current when this hook runs.
920 ** =org-remember-mode-hook=
921 Defined in: /org-remember.el/
923 Hook for the minor `org-remember-mode'.
925 ** =org-src-mode-hook=
926 Defined in: /org-src.el/
928 Hook run after Org switched a source code snippet to its Emacs mode.
931 - when editing a source code snippet with \"C-c '\".
932 - When formatting a source code snippet for export with htmlize.
934 You may want to use this hook for example to turn off `outline-minor-mode'
935 or similar things which you want to have when editing a source code file,
936 but which mess up the display of a snippet in Org exported files.
938 ** =org-timer-start-hook=
939 Defined in: /org-timer.el/
941 Hook run after relative timer is started.
943 ** =org-timer-stop-hook=
944 Defined in: /org-timer.el/
946 Hook run before relative timer is stopped.
948 ** =org-timer-pause-hook=
949 Defined in: /org-timer.el/
951 Hook run before relative timer is paused.
953 ** =org-timer-set-hook=
954 Defined in: /org-timer.el/
956 Hook run after countdown timer is set.
958 ** =org-timer-done-hook=
959 Defined in: /org-timer.el/
961 Hook run after countdown timer reaches zero.
963 ** =org-timer-cancel-hook=
964 Defined in: /org-timer.el/
966 Hook run before countdown timer is canceled.
968 ** =org-export-xoxo-final-hook=
969 Defined in: /org-xoxo.el/
971 Hook run after XOXO export, in the new buffer.
973 * Examples for using hooks
975 Feel free to give example of how do you use these hooks. Ideas for
976 other hooks are also welcome.
978 ** org-follow-link-hook :bzg:
980 If you want to display dormant article when following Gnus articles:
982 #+BEGIN_SRC emacs-lisp
983 (add-hook 'org-follow-link-hook
984 (lambda () (if (eq major-mode 'gnus-summary-mode)
985 (gnus-summary-insert-dormant-articles))))
988 ** org-agenda-after-show-hook
990 To get a compact view during follow mode in the agenda, you could try
993 #+begin_src emacs-lisp
994 (defun my-compact-follow ()
995 "Make the view compact, then show the necessary minimum."
998 (while (org-up-heading-safe))
1000 (let ((org-show-siblings nil)
1001 (org-show-hierarchy-above t))
1004 (org-back-to-heading t)
1007 (add-hook 'org-agenda-after-show-hook 'my-compact-follow)