Variable: org-agenda-custom-commands-contexts
org-agenda-custom-commands-contexts is a customizable variable defined
in org-agenda.el.gz.
Value
nil
Documentation
Alist of custom agenda keys and contextual rules.
For example, if you have a custom agenda command "p" and you want this command to be accessible only from plain text files, use this:
(setq org-agenda-custom-commands-contexts
'(("p" ((in-file . "\\\\.txt\\\\'")))))
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 agenda custom command depending on contextual rules.
(setq org-agenda-custom-commands-contexts
'(("p" "q" ((in-file . "\\\\.txt\\\\'")))))
Here it means: in .txt files, use "p" as the key for the agenda command otherwise associated with "q". (The command originally associated with "q" 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-agenda.el.gz
(defcustom org-agenda-custom-commands-contexts nil
"Alist of custom agenda keys and contextual rules.
For example, if you have a custom agenda command \"p\" and you
want this command to be accessible only from plain text files,
use this:
(setq org-agenda-custom-commands-contexts
\\='((\"p\" ((in-file . \"\\\\.txt\\\\'\")))))
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 agenda custom command
depending on contextual rules.
(setq org-agenda-custom-commands-contexts
\\='((\"p\" \"q\" ((in-file . \"\\\\.txt\\\\'\")))))
Here it means: in .txt files, use \"p\" as the key for the
agenda command otherwise associated with \"q\". (The command
originally associated with \"q\" is not displayed to avoid
duplicates.)"
:version "24.3"
:group 'org-agenda-custom-commands
:type '(repeat (list :tag "Rule"
(string :tag " Agenda key")
(string :tag "Replace by command")
(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"))))))