emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Capture aborts after selecting template


From: Bernt Hansen
Subject: Re: [O] Capture aborts after selecting template
Date: Sat, 26 Nov 2011 14:46:53 -0500
User-agent: Gnus/5.110018 (No Gnus v0.18) Emacs/23.2 (gnu/linux)

Felix <address@hidden> writes:

>> 
>> I think the problem is your 'nil' entries.
>> 
>> My text-mode-hook looks like this:
>> 
>> --8<---------------cut here---------------start------------->8---
>> text-mode-hook's value is 
>> (text-mode-hook-identify)
>> --8<---------------cut here---------------end--------------->8---
>> 

<snip>

>> 
>
> Please forgive the question, but how do you remove the nil entries?
>
> In .emacs I have (add-hook 'text-mode-hook (setq adaptive-fill-mode nil))
> and so I'm not sure how text-mode-hook ends up with (nil
> (text-mode-hook-identify)). 
>
> I tried (add-hook 'text-mode-hook (text-mode-hook-identify)) but this set
> text-mode-hook to (t text-mode-hook-identify) and when I tried C-c c t
> to enter a task, I get the message "Capture template 't':
> org-called-interactively-p" and nothing happens.

I think your add-hook is used wrong and is what is causing your problem.
Your add-hook call is inserting nil and not a function that sets the
variable you want to nil.

If you want to set adaptive-fill-mode to nil you need something like
this instead:

(add-hook 'text-mode-hook '(lambda () (setq adaptive-fill-mode nil)))

which is an anonymous function that sets adaptive-fill-mode to nil.

Your original case inserts a list where nil is one of the elements and
this is trying to be invoked as a function which causes the failure you
are seeing.

Before your original hook was called text-mode-hook's value is
(text-mode-hook-identify)

Your original value after running your incorrect hook was
--8<---------------cut here---------------start------------->8---
text-mode-hook's value is 
(nil text-mode-hook-identify)
--8<---------------cut here---------------end--------------->8---

which is the result of your add-hook call with (setq adaptive-fill-mode
nil).  This evaluates your setq immediately and returns the result nil
which you add to your text-mode-hook (at the front)

You need to provide a function that the hook can invoke (it's
essentially a list of functions to call).  If you don't want to
explicitly name your functions with defun then you can use a lambda
anonymous function instead.

When you changed your hook and got 't' it was probably run from some
buffer already in text mode - so (text-mode-hook-identify) returns t.
Your second try should have been like this instead

(add-hook 'text-mode-hook 'text-mode-hook-identify)
or
(setq text-mode-hook 'text-mode-hook-identify) if there was already
stuff in the hook you want to clear out.

The quote prevents evaluation of the form you provide for the hook so
that you can evaluate it later.

HTH,
Bernt



reply via email to

[Prev in Thread] Current Thread [Next in Thread]