On May 7, 2008, at 1:39 PM, Richard KLINDA wrote:

Regarding 'Re: Property for startup visibility?'; Peter Jones adds:


Richard KLINDA <[EMAIL PROTECTED]> 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)



_______________________________________________
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

Reply via email to