emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Bernt Hansen <bernt@norang.ca>
To: Felix <felixfcaf@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: Capture aborts after selecting template
Date: Sat, 26 Nov 2011 14:46:53 -0500	[thread overview]
Message-ID: <87ipm6fyz6.fsf@norang.ca> (raw)
In-Reply-To: loom.20111126T164932-314@post.gmane.org

Felix <felixfcaf@gmail.com> 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	other threads:[~2011-11-26 19:47 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-26 10:42 Capture aborts after selecting template Felix
2011-11-26 12:24 ` Bernt Hansen
2011-11-26 14:34   ` Felix
2011-11-26 15:35     ` Bernt Hansen
2011-11-26 15:56       ` Felix
2011-11-26 19:46         ` Bernt Hansen [this message]
2011-11-27  9:11           ` Felix

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ipm6fyz6.fsf@norang.ca \
    --to=bernt@norang.ca \
    --cc=emacs-orgmode@gnu.org \
    --cc=felixfcaf@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).