From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: fold only DONE items at #+STARTUP Date: Thu, 30 Jan 2014 18:22:33 -0500 Message-ID: <87y51x5a2u.fsf@gmail.com> References: <8761p2fzk3.fsf@bzg.ath.cx> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:37669) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W90wg-0007of-Dd for emacs-orgmode@gnu.org; Thu, 30 Jan 2014 18:23:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W90wa-0004wF-Jj for emacs-orgmode@gnu.org; Thu, 30 Jan 2014 18:22:54 -0500 Received: from plane.gmane.org ([80.91.229.3]:49494) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W90wa-0004w0-De for emacs-orgmode@gnu.org; Thu, 30 Jan 2014 18:22:48 -0500 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1W90wY-0006Eq-TA for emacs-orgmode@gnu.org; Fri, 31 Jan 2014 00:22:46 +0100 Received: from pool-98-110-175-184.bstnma.fios.verizon.net ([98.110.175.184]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 31 Jan 2014 00:22:46 +0100 Received: from ndokos by pool-98-110-175-184.bstnma.fios.verizon.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 31 Jan 2014 00:22:46 +0100 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: emacs-orgmode@gnu.org Piotr Isajew writes: > Hi Bastien, > > Dnia 29.01.2014 Bastien napisaƂ/a: > >> Piotr Isajew writes: >> >>> For example, when I open .org file I would like to have subtrees >>> marked as DONE folded, but the others should be opened as with >>> #+STARTUP: content setting. Can it be done? >> >> No. But you can archive the DONE subtrees with C-c C-x C-a for >> example. See "Archiving" in Org's manual. > > I haven't thought about archiving so thanks for pointing me to > this. In general that could be the solution, but for this case it > seems too drastic. It would mean excluding DONE subtrees from > searches and clock reports which I don't want to happen before I > finish entire project. What I want is just to initially get DONE > subtrees out of my sight. > > I was able to achieve more or less what I wanted by setting > VISIBILITY property with a hook: > > (defun set-visibility-to-folded-when-done() > "Change default subtree VISIBILITY to folded when state is changed to DONE" > ( when (string= org-state "DONE") > (org-set-property "VISIBILITY" "folded")) > ) > (add-hook 'org-after-todo-state-change-hook > 'set-visibility-to-folded-when-done) > You might want to augment your function slightly with a call to org-set-startup-visibility: --8<---------------cut here---------------start------------->8--- (defun set-visibility-to-folded-when-done() "Change default subtree VISIBILITY to folded when state is changed to DONE" (when (string= org-state "DONE") (org-set-property "VISIBILITY" "folded") (org-set-startup-visibility))) --8<---------------cut here---------------end--------------->8--- That will fold the item immediately. -- Nick