From bbea8d348b7972e0b29727f328f7f4dd92f18def Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Thu, 31 Jan 2013 11:06:04 +0100 Subject: [PATCH] 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. --- lisp/org-agenda.el | 4 ++++ lisp/org-capture.el | 4 ++++ lisp/org.el | 6 +++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index f3ffa8e78..2ce9f206e 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 639a490e6..2ca523940 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 651182aab..310972b4f 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)))) -- 2.11.4.GIT