From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: Re: Property for startup visibility? Date: Wed, 7 May 2008 17:23:34 +0200 Message-ID: <3B5FB20C-6B72-4C69-9374-85FCC2F33173@science.uva.nl> References: <87d4nz6xtb.fsf@gmail.com> <87abj2jqc8.fsf@gmail.com> Mime-Version: 1.0 (Apple Message framework v919.2) Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JtlUa-0006Mj-5r for emacs-orgmode@gnu.org; Wed, 07 May 2008 11:23:40 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JtlUZ-0006Lw-AR for emacs-orgmode@gnu.org; Wed, 07 May 2008 11:23:39 -0400 Received: from [199.232.76.173] (port=51787 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JtlUZ-0006Lo-4H for emacs-orgmode@gnu.org; Wed, 07 May 2008 11:23:39 -0400 Received: from korteweg.uva.nl ([146.50.98.70]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JtlUY-0006SF-OA for emacs-orgmode@gnu.org; Wed, 07 May 2008 11:23:38 -0400 In-Reply-To: <87abj2jqc8.fsf@gmail.com> 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: Richard KLINDA Cc: emacs-orgmode@gnu.org On May 7, 2008, at 1:39 PM, Richard KLINDA wrote: >>>>>> Regarding 'Re: Property for startup visibility?'; Peter Jones >>>>>> adds: > > >> Richard KLINDA writes: >>> Hello, is there a property for setting the startup visibility >>> (folden, children or subtree) of a tree? > >> Place this in your .org file. I keep it near the top: > >> #+STARTUP: showall > >> Search the manual for "startup" for more options. > > Thanks, but I would like to set this up on a tree-by-tree basis > (complementing the #+STARTUP option). Hmmm, I see now what you mean. I am not convinced how useful this would be, because I suspect that the visibility you'd like will often change? Something like this is easily hacked, see below. Why don't you test it a while and then report back with a good example and use case. Then we can make a decision about including it. The following looks for a :visibility: property with value "folded" or "children" or "all". Installing it in the hook will run it after the global STARTUP visibility has been set. - Carsten (defun org-property-visibility () "Switch subtree visibility according to :visibility: property." (interactive) (let (state) (save-excursion (goto-char (point-min)) (while (re-search-forward "^[ \t]*:visibility:[ \t]+\\([a-z]+\\)" nil t) (setq state (match-string 1)) (save-excursion (org-back-to-heading t) (hide-subtree) (org-reveal) (cond ((equal state "children") (org-show-hidden-entry) (show-children)) ((equal state "all") (show-subtree))))) (org-cycle-hide-drawers 'all)))) (add-hook 'org-mode-hook 'org-property-visibility)