I've got this for three capture templates that should only work in Gnus: (setq org-capture-templates-contexts '(("M" ((in-mode . "gnus-\\(summary\\|article\\)"))) ("P" ((in-mode . "gnus-\\(summary\\|article\\)"))) ("H" ((in-mode . "gnus-\\(summary\\|article\\)"))))) This worked for quite some time, but when I went back to use it again today I found that these templates aren't filtered out in non-Gnus settings. I tried stepping through the code of `org-contextualize-validate-key' and think I've found the problem, though I'll confess to a little confusion. When that function checks the predicates (in-mode, not-in-file, etc), it has this chunk for handling the not-in-file bit: (if (and (eq (car rr) 'not-in-file) (buffer-file-name)) (not (string-match (cdr rr) (buffer-file-name))) t) This was slightly mis-aligned in the source file, leading me to believe it's just a nesting error. As it is, any template which *isn't using* the not-in-file predicate is going to flag as acceptable for the current context. I think it should just be: (when (and (eq (car rr) 'not-in-file) (buffer-file-name)) (not (string-match (cdr rr) (buffer-file-name)))) Testing indicates it works, am I missing anything? Pickaxe search for the string "not-in-file" in git says the last relevant commit was two years ago, so who knows what's going on... Eric
Hi Eric,
Eric Abrahamsen <eric@ericabrahamsen.net> writes:
> This was slightly mis-aligned in the source file, leading me to believe
> it's just a nesting error. As it is, any template which *isn't using*
> the not-in-file predicate is going to flag as acceptable for the current
> context. I think it should just be:
>
> (when (and (eq (car rr) 'not-in-file)
> (buffer-file-name))
> (not (string-match (cdr rr) (buffer-file-name))))
>
> Testing indicates it works, am I missing anything?
You are not!
You just nailed down something quite not obvious.
I applied the change in maint, thanks a lot for tracking this,
--
Bastien
Bastien <bzg@gnu.org> writes:
> Hi Eric,
>
> Eric Abrahamsen <eric@ericabrahamsen.net> writes:
>
>> This was slightly mis-aligned in the source file, leading me to believe
>> it's just a nesting error. As it is, any template which *isn't using*
>> the not-in-file predicate is going to flag as acceptable for the current
>> context. I think it should just be:
>>
>> (when (and (eq (car rr) 'not-in-file)
>> (buffer-file-name))
>> (not (string-match (cdr rr) (buffer-file-name))))
>>
>> Testing indicates it works, am I missing anything?
>
> You are not!
>
> You just nailed down something quite not obvious.
>
> I applied the change in maint, thanks a lot for tracking this,
Oh good -- my pleasure!