From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bastien Subject: Re: Bug: Problem with hook added to org-mode-hook [8.2.6 (release_8.2.6-1 @ /usr/local/share/emacs/24.4.50/lisp/org/)] Date: Mon, 28 Jul 2014 11:25:43 +0200 Message-ID: <87d2cp2y6s.fsf@bzg.ath.cx> References: <87ha2kzcdm.fsf@localhost.localdomain.i-did-not-set--mail-host-address--so-tickle-me> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:59745) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XBofn-0007TG-E6 for emacs-orgmode@gnu.org; Mon, 28 Jul 2014 13:25:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XBofY-0005jQ-9E for emacs-orgmode@gnu.org; Mon, 28 Jul 2014 13:25:19 -0400 Received: from mail-s76.mailgun.info ([184.173.153.204]:51196) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XBofY-0005Un-6F for emacs-orgmode@gnu.org; Mon, 28 Jul 2014 13:25:04 -0400 In-Reply-To: <87ha2kzcdm.fsf@localhost.localdomain.i-did-not-set--mail-host-address--so-tickle-me> (Tianxiang Xiong's message of "Mon, 14 Jul 2014 01:24:21 -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: Tianxiang Xiong Cc: emacs-orgmode@gnu.org Hi Tianxiang, Tianxiang Xiong writes: > (add-hook 'org-mode-hook > (lambda () > (add-hook 'after-save-hook 'tangle-init nil t))) > > However, when I open my init.org file, I see that the after-save-hook > variable is nil. If I manually reapply org-mode, however, it works as > expected. If you define the hook then kill the buffer containing init.org then reopens it, you don't need to manually M-x org-mode RET in order for the hook to be taken into account. IOW: the hook runs fine, it's just that your buffer was already in org-mode. Can you confirm this? To me (add-hook 'after-save-hook (lambda () (when (derived-mode-p 'org-mode) (tangle-init))) seems more "natural" anyway. Thanks, -- Bastien