From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bastien Subject: Re: Re: Showing hidden subtree automatically if point is hidden when the buffer is opened Date: Wed, 29 Jul 2009 02:27:41 +0800 Message-ID: <87ab2ou09h.fsf@bzg.ath.cx> References: <878wi9agq8.fsf@bzg.ath.cx> <87y6q93tay.fsf@bzg.ath.cx> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MVrTL-0000So-GG for emacs-orgmode@gnu.org; Tue, 28 Jul 2009 14:32:23 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MVrTJ-0000Sc-9c for emacs-orgmode@gnu.org; Tue, 28 Jul 2009 14:32:22 -0400 Received: from [199.232.76.173] (port=58573 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MVrTJ-0000SZ-3F for emacs-orgmode@gnu.org; Tue, 28 Jul 2009 14:32:21 -0400 In-Reply-To: <87y6q93tay.fsf@bzg.ath.cx> (Bastien's message of "Tue, 28 Jul 2009 19:59:35 +0800") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Bastien Cc: User , emacs-orgmode@gnu.org Bastien writes: > User writes: > >> I added the timer, because I didn't know in which order the hooks >> are run. If org-mode hook runs first and then saveplace's hook >> which restores point then the above code has no effect. > > saveplace adds the hook at the end of the hooks list, by calling > add-hook like this: > > (add-hook 'find-file-hook 'save-place-find-file-hook t) > ^ > > The `t' means put this hook at the end. > > So your org-mode hook will be safely called *before* saveplace's. Sorry, I mixed up the logic here -- the following hook is okay: --8<---------------cut here---------------start------------->8--- (add-hook 'org-mode-hook (lambda () (when (outline-invisible-p) (save-excursion (outline-previous-visible-heading 1) (org-show-subtree)))) t) ;; this makes sure this hook is run last --8<---------------cut here---------------end--------------->8--- If you load this *after* loading the saveplace hook then it should be okay. Thanks to Nick Dokos for shaking my brain on this :) -- Bastien