Variable: org-capture-templates-contexts

org-capture-templates-contexts is a customizable variable defined in org-capture.el.gz.

Value

nil

Documentation

Alist of capture templates and valid contexts.

For example, if you have a capture template "c" and you want this template to be accessible only from message-mode buffers, use this:

  (setq org-capture-templates-contexts
        '(("c" ((in-mode . "message-mode")))
            ("d" (my-context-function
                    (in-mode . "org-mode")))))

Here are the available contexts definitions:

      in-file: command displayed only in matching files
      in-mode: command displayed only in matching modes
  not-in-file: command not displayed in matching files
  not-in-mode: command not displayed in matching modes
    in-buffer: command displayed only in matching buffers
not-in-buffer: command not displayed in matching buffers
   [function]: a custom function taking no argument

If you define several checks, the agenda command will be accessible if there is at least one valid check.

You can also bind a key to another capture template depending on contextual rules.

  (setq org-capture-templates-contexts
        '(("c" "d" ((in-mode . "message-mode")))))

Here it means: in message-mode buffers, use "c" as the key for the capture template otherwise associated with "d".
(The template originally associated with "d" is not displayed
to avoid duplicates.)

This variable was added, or its default value changed, in Emacs 24.3.

Source Code

;; Defined in /usr/src/emacs/lisp/org/org-capture.el.gz
(defcustom org-capture-templates-contexts nil
  "Alist of capture templates and valid contexts.

For example, if you have a capture template \"c\" and you want
this template to be accessible only from `message-mode' buffers,
use this:

  (setq org-capture-templates-contexts
        \\='((\"c\" ((in-mode . \"message-mode\")))
            (\"d\" (my-context-function
                    (in-mode . \"org-mode\")))))

Here are the available contexts definitions:

      in-file: command displayed only in matching files
      in-mode: command displayed only in matching modes
  not-in-file: command not displayed in matching files
  not-in-mode: command not displayed in matching modes
    in-buffer: command displayed only in matching buffers
not-in-buffer: command not displayed in matching buffers
   [function]: a custom function taking no argument

If you define several checks, the agenda command will be
accessible if there is at least one valid check.

You can also bind a key to another capture template depending on
contextual rules.

  (setq org-capture-templates-contexts
        \\='((\"c\" \"d\" ((in-mode . \"message-mode\")))))

Here it means: in `message-mode buffers', use \"c\" as the
key for the capture template otherwise associated with \"d\".
\(The template originally associated with \"d\" is not displayed
to avoid duplicates.)"
  :version "24.3"
  :group 'org-capture
  :type '(repeat (list :tag "Rule"
		       (string :tag "        Capture key")
		       (string :tag "Replace by template")
		       (repeat :tag "Available when"
			       (choice
                                (cons :tag "Condition"
				      (choice
				       (const :tag "In file" in-file)
				       (const :tag "Not in file" not-in-file)
				       (const :tag "In buffer" in-buffer)
				       (const :tag "Not in buffer" not-in-buffer)
				       (const :tag "In mode" in-mode)
				       (const :tag "Not in mode" not-in-mode))
				      (regexp))
                                (function :tag "Custom function"))))))