emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Capture aborts after selecting template
@ 2011-11-26 10:42 Felix
  2011-11-26 12:24 ` Bernt Hansen
  0 siblings, 1 reply; 7+ messages in thread
From: Felix @ 2011-11-26 10:42 UTC (permalink / raw)
  To: emacs-orgmode

I am using GNU Emacs 23.1.1 with org-mode version 7.7. I want to use C-c c t to
capture a task and send it to ~/todo.org as defined in the org-capture-template
 below. On pressing C-c c, the Org Select buffer opens but when I hit t, I get
the error message "Capture abort: (void-function nil)" and nothing gets written
to todo.org. The relevant lines from my
.emacs and a backtrace from uncompiled code are shown below.  Please help me fix
this.  

.EMACS
(define-key global-map "\C-cc" 'org-capture)
(setq org-directory "~/")

(setq org-capture-templates
      (quote 
      (("t" "Todo" entry (file+headline "~/todo.org" "Tasks")
             "* TODO %?\n  %i\n  %a")
        ("j" "Journal" entry (file+datetree "~/journal.org")
             "* %?\nEntered on %U\n  %i\n  %a"))))

BACKTRACE (Although I followed the instructions carefully, my backtrace still
has some byte code that I couldn't paste here.)
Debugger entered--Lisp error: (void-function nil)
  nil()
  run-hooks(text-mode-hook outline-mode-hook org-mode-hook)
  apply(run-hooks (text-mode-hook outline-mode-hook org-mode-hook))
  run-mode-hooks(org-mode-hook)
  org-mode()
  set-auto-mode-0(org-mode nil)
  byte-code(..."*Ň" [modes mode --dolist-tail-- done keep-mode-if-same nil
functionp message "Ignoring unknown mode `%s'" t set-auto-mode-0 throw nop] 4)
  set-auto-mode()
  normal-mode(t)
  after-find-file(nil t)
  find-file-noselect-1(#<buffer todo.org> "~/todo.org" nil nil "~/todo.org"
(305483 2049))
  find-file-noselect("/home/vadmin/todo.org")
  org-capture-target-buffer("~/todo.org")
  org-capture-set-target-location()
  org-capture(nil)
  call-interactively(org-capture nil nil)

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Capture aborts after selecting template
  2011-11-26 10:42 Capture aborts after selecting template Felix
@ 2011-11-26 12:24 ` Bernt Hansen
  2011-11-26 14:34   ` Felix
  0 siblings, 1 reply; 7+ messages in thread
From: Bernt Hansen @ 2011-11-26 12:24 UTC (permalink / raw)
  To: Felix; +Cc: emacs-orgmode

Felix <felixfcaf@gmail.com> writes:

> I am using GNU Emacs 23.1.1 with org-mode version 7.7. I want to use C-c c t to
> capture a task and send it to ~/todo.org as defined in the org-capture-template
>  below. On pressing C-c c, the Org Select buffer opens but when I hit t, I get
> the error message "Capture abort: (void-function nil)" and nothing gets written
> to todo.org. The relevant lines from my
> .emacs and a backtrace from uncompiled code are shown below.  Please help me fix
> this.  
>
> .EMACS
> (define-key global-map "\C-cc" 'org-capture)
> (setq org-directory "~/")
>
> (setq org-capture-templates
>       (quote 
>       (("t" "Todo" entry (file+headline "~/todo.org" "Tasks")
>              "* TODO %?\n  %i\n  %a")
>         ("j" "Journal" entry (file+datetree "~/journal.org")
>              "* %?\nEntered on %U\n  %i\n  %a"))))
>
> BACKTRACE (Although I followed the instructions carefully, my backtrace still
> has some byte code that I couldn't paste here.)
> Debugger entered--Lisp error: (void-function nil)
>   nil()
>   run-hooks(text-mode-hook outline-mode-hook org-mode-hook)
>   apply(run-hooks (text-mode-hook outline-mode-hook org-mode-hook))

Hi Felix,

What are your values for text-mode-hook, outline-mode-hook, and
org-mode-hook?

From your backtrace it looks like invoking one of these hooks is the
problem.

Regards,
Bernt

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Capture aborts after selecting template
  2011-11-26 12:24 ` Bernt Hansen
@ 2011-11-26 14:34   ` Felix
  2011-11-26 15:35     ` Bernt Hansen
  0 siblings, 1 reply; 7+ messages in thread
From: Felix @ 2011-11-26 14:34 UTC (permalink / raw)
  To: emacs-orgmode

Thanks, Bernt. The values are as shown below. Please suggest any changes.

Sincerely,
Felix

text-mode-hook's value is 
(nil text-mode-hook-identify)

outline-mode-hook's value is nil

org-mode-hook is a variable defined in `org.el'.
Its value is 
(#[nil "\300\301\302\303\304$\207"
       [org-add-hook change-major-mode-hook org-show-block-all append local]
       5]
 #[nil "\300\301\302\303\304$\207"
       [org-add-hook change-major-mode-hook org-babel-show-result-all append local]
       5]
 org-babel-result-hide-spec org-babel-hide-all-hashes)

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Capture aborts after selecting template
  2011-11-26 14:34   ` Felix
@ 2011-11-26 15:35     ` Bernt Hansen
  2011-11-26 15:56       ` Felix
  0 siblings, 1 reply; 7+ messages in thread
From: Bernt Hansen @ 2011-11-26 15:35 UTC (permalink / raw)
  To: Felix; +Cc: emacs-orgmode

Felix <felixfcaf@gmail.com> writes:

> Thanks, Bernt. The values are as shown below. Please suggest any changes.
>
> Sincerely,
> Felix
>
> text-mode-hook's value is 
> (nil text-mode-hook-identify)
>
> outline-mode-hook's value is nil
>
> org-mode-hook is a variable defined in `org.el'.
> Its value is 
> (#[nil "\300\301\302\303\304$\207"
>        [org-add-hook change-major-mode-hook org-show-block-all append local]
>        5]
>  #[nil "\300\301\302\303\304$\207"
>        [org-add-hook change-major-mode-hook org-babel-show-result-all append local]
>        5]
>  org-babel-result-hide-spec org-babel-hide-all-hashes)

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---

I would remove the nil entries and see if that helps

My org-mode-hook looks like this:
--8<---------------cut here---------------start------------->8---
Value: 
(org-clock-load
 (lambda nil
   (abbrev-mode 1))
 (lambda nil
   (add-hook 'before-save-hook 'org-encrypt-entries nil t))
 (lambda nil
   (org-add-hook 'change-major-mode-hook 'org-show-block-all 'append 'local))
 (lambda nil
   (org-add-hook 'change-major-mode-hook 'org-babel-show-result-all 'append 'local))
 org-babel-result-hide-spec org-babel-hide-all-hashes turn-on-flyspell
 (lambda nil
   (org-defkey org-mode-map "[" 'undefined)
   (org-defkey org-mode-map "]" 'undefined))
 (lambda nil
   (local-set-key
    (kbd "C-c M-o")
    'bh/mail-subtree)))
--8<---------------cut here---------------end--------------->8---

I'm on GNU Emacs 23.2.1 (i486-pc-linux-gnu, GTK+ Version 2.20.0) of 2010-12-11 on raven, modified by Debian

Regards,
Bernt

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Capture aborts after selecting template
  2011-11-26 15:35     ` Bernt Hansen
@ 2011-11-26 15:56       ` Felix
  2011-11-26 19:46         ` Bernt Hansen
  0 siblings, 1 reply; 7+ messages in thread
From: Felix @ 2011-11-26 15:56 UTC (permalink / raw)
  To: emacs-orgmode

> 
> 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---
> 
> I would remove the nil entries and see if that helps
> 
> My org-mode-hook looks like this:
> --8<---------------cut here---------------start------------->8---
> Value: 
> (org-clock-load
>  (lambda nil
>    (abbrev-mode 1))
>  (lambda nil
>    (add-hook 'before-save-hook 'org-encrypt-entries nil t))
>  (lambda nil
>    (org-add-hook 'change-major-mode-hook 'org-show-block-all 'append 'local))
>  (lambda nil
>    (org-add-hook 'change-major-mode-hook 'org-babel-show-result-all 'append
'local))
>  org-babel-result-hide-spec org-babel-hide-all-hashes turn-on-flyspell
>  (lambda nil
>    (org-defkey org-mode-map "[" 'undefined)
>    (org-defkey org-mode-map "]" 'undefined))
>  (lambda nil
>    (local-set-key
>     (kbd "C-c M-o")
>     'bh/mail-subtree)))
> --8<---------------cut here---------------end--------------->8---
> 
> I'm on GNU Emacs 23.2.1 (i486-pc-linux-gnu, GTK+ Version 2.20.0) of 2010-12-11
on raven, modified by Debian
> 
> Regards,
> Bernt
> 
> 

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.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Capture aborts after selecting template
  2011-11-26 15:56       ` Felix
@ 2011-11-26 19:46         ` Bernt Hansen
  2011-11-27  9:11           ` Felix
  0 siblings, 1 reply; 7+ messages in thread
From: Bernt Hansen @ 2011-11-26 19:46 UTC (permalink / raw)
  To: Felix; +Cc: emacs-orgmode

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Capture aborts after selecting template
  2011-11-26 19:46         ` Bernt Hansen
@ 2011-11-27  9:11           ` Felix
  0 siblings, 0 replies; 7+ messages in thread
From: Felix @ 2011-11-27  9:11 UTC (permalink / raw)
  To: emacs-orgmode

Bernt Hansen <bernt <at> norang.ca> writes:

> <snip>
> 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)))
> 
> <snip>

Thanks for the detailed explanation. I added 
  (add-hook 'text-mode-hook '(lambda () (setq adaptive-fill-mode nil)))
as suggested. It didn't work at first, but then when I did C-u C-c C-x r to
"reload org uncompiled" and generate a backtrace, it did work and I was able to
use capture to add a todo list. The current status is that I have to reload org
uncompiled every time I restart emacs to get capture to work. The situation is
the same even when I comment out the preceding add-hook for text-mode-hook.  Any
idea how to fix this? 

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-11-27  9:12 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2011-11-27  9:11           ` Felix

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).