summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Guerry <bzg@altern.org>2013-01-31 10:06:04 (GMT)
committer Bastien Guerry <bzg@altern.org>2013-01-31 10:06:04 (GMT)
commitbbea8d348b7972e0b29727f328f7f4dd92f18def (patch)
treeee4bd86f2a41733f50bd22281f823a65835d9782
parentb9c506b41e5d989241263b824ce9b8fb5182f1af (diff)
downloadorg-mode-bbea8d348b7972e0b29727f328f7f4dd92f18def.zip
org-mode-bbea8d348b7972e0b29727f328f7f4dd92f18def.tar.gz
Allow to contextualize capture and agenda commands by checking the name of the buffer
* org.el (org-contextualize-validate-key): Check against two new context predicates [not-]in-buffer. * org-capture.el (org-capture-templates-contexts): * org-agenda.el (org-agenda-custom-commands-contexts): Document the new [not-]in-buffer context predicates. Thanks to Paul Sexton for triggering this and for proposing a patch.
-rw-r--r--lisp/org-agenda.el4
-rw-r--r--lisp/org-capture.el4
-rw-r--r--lisp/org.el6
3 files changed, 13 insertions, 1 deletions
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index f3ffa8e..2ce9f20 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -2423,6 +2423,8 @@ Here are the available contexts definitions:
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
@@ -2448,6 +2450,8 @@ duplicates.)"
(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))
diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index 639a490..2ca5239 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -461,6 +461,8 @@ Here are the available contexts definitions:
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
@@ -486,6 +488,8 @@ to avoid duplicates.)"
(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))
diff --git a/lisp/org.el b/lisp/org.el
index 651182a..310972b 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -8729,11 +8729,15 @@ definitions."
(string-match (cdr rr) (buffer-file-name)))
(and (eq (car rr) 'in-mode)
(string-match (cdr rr) (symbol-name major-mode)))
+ (and (eq (car rr) 'in-buffer)
+ (string-match (cdr rr) (buffer-name)))
(when (and (eq (car rr) 'not-in-file)
(buffer-file-name))
(not (string-match (cdr rr) (buffer-file-name))))
(when (eq (car rr) 'not-in-mode)
- (not (string-match (cdr rr) (symbol-name major-mode)))))))
+ (not (string-match (cdr rr) (symbol-name major-mode))))
+ (when (eq (car rr) 'not-in-buffer)
+ (not (string-match (cdr rr) (buffer-name)))))))
(push r res)))
(car (last r))))
(delete-dups (delq nil res))))