From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bastien Subject: Re: Showing hidden subtree automatically if point is hidden when the buffer is opened Date: Tue, 28 Jul 2009 04:45:55 +0800 Message-ID: <878wi9agq8.fsf@bzg.ath.cx> References: 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 1MVYvz-0006c3-N6 for emacs-orgmode@gnu.org; Mon, 27 Jul 2009 18:44:43 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MVYvt-0006Xx-NP for emacs-orgmode@gnu.org; Mon, 27 Jul 2009 18:44:42 -0400 Received: from [199.232.76.173] (port=56401 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MVYvt-0006Xk-JH for emacs-orgmode@gnu.org; Mon, 27 Jul 2009 18:44:37 -0400 Received: from mail-pz0-f202.google.com ([209.85.222.202]:48600) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MVYvt-0001Ru-76 for emacs-orgmode@gnu.org; Mon, 27 Jul 2009 18:44:37 -0400 Received: by mail-pz0-f202.google.com with SMTP id 40so2255348pzk.14 for ; Mon, 27 Jul 2009 15:44:36 -0700 (PDT) In-Reply-To: (User's message of "Mon, 27 Jul 2009 14:00:07 +0000 (UTC)") 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: User Cc: emacs-orgmode@gnu.org User writes: > I use folded view by default, but I also use saveplace.el, > because it's nice to continue from the point I left off in the > buffer, instead of navigating there again manually. > > The problem is the restored point can be in an automatically > folded section when the buffer is opened, so I added this little > code to my org-mode hook which opens the subtree automatically if > point is hidden: > > (run-with-idle-timer 0 nil > (lambda () > (when (outline-invisible-p) > (save-excursion > (outline-previous-visible-heading 1) > (org-show-subtree))))) > > I haven't seen an option for this in org, so I post the code > here if someone has a similar problem. I added this entry on org-hacks.org (Worg): Fix a problem with saveplace.el putting you back in a folded position: #+begin_src emacs-lisp (add-hook 'org-mode-hook (lambda () (when (outline-invisible-p) (save-excursion (outline-previous-visible-heading 1) (org-show-subtree))))) #+end_src Note that I removed the timer - no sure why it was useful. Feel free to modify this hack the way you want on Worg. -- Bastien