From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bernt Hansen Subject: Re: Capture aborts after selecting template Date: Sat, 26 Nov 2011 14:46:53 -0500 Message-ID: <87ipm6fyz6.fsf@norang.ca> References: <87y5v3f4wq.fsf@norang.ca> <87ty5qgamv.fsf@norang.ca> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([140.186.70.92]:46203) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RUODF-0000qj-Qs for emacs-orgmode@gnu.org; Sat, 26 Nov 2011 14:47:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RUODE-0004nZ-IH for emacs-orgmode@gnu.org; Sat, 26 Nov 2011 14:47:01 -0500 Received: from mho-03-ewr.mailhop.org ([204.13.248.66]:43913 helo=mho-01-ewr.mailhop.org) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RUODE-0004nQ-FF for emacs-orgmode@gnu.org; Sat, 26 Nov 2011 14:47:00 -0500 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Felix Cc: emacs-orgmode@gnu.org Felix 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--- >> >> > > 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