From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: Re: Save-excursion that works with org visibility? Date: Sun, 14 May 2017 08:16:37 -0400 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:38212) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d9sS5-0004nu-Oq for emacs-orgmode@gnu.org; Sun, 14 May 2017 08:16:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d9sS2-0001MU-Hm for emacs-orgmode@gnu.org; Sun, 14 May 2017 08:16:45 -0400 Received: from mail-qt0-x22d.google.com ([2607:f8b0:400d:c0d::22d]:36421) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d9sS2-0001LP-CH for emacs-orgmode@gnu.org; Sun, 14 May 2017 08:16:42 -0400 Received: by mail-qt0-x22d.google.com with SMTP id f55so26314105qta.3 for ; Sun, 14 May 2017 05:16:41 -0700 (PDT) In-reply-to: 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" To: Nikolay Kudryavtsev Cc: emacs-orgmode@gnu.org Is org-save-outline-visibility what you are looking for? Nikolay Kudryavtsev writes: > Is there any way to modify node visibility and then revert those > changes? In particular I'm interested in doing and then reverting > (org-content). > > What follows is more details at what I'm trying to accomplish in the end. > > Let's say we have nodes: > * A > ** B > *** TODO =D0=A1 > For task node C I want to see which parent node has tag "project" and > then put it into a prefix in agenda. Here's my code: > =3D=3D=3D > (defun org-get-task-project () > (let ((project "")) > (save-excursion > (org-content) > (while > (progn > (ignore-errors (outline-up-heading 1)) > (when (and (eq project "") > (member "project" (org-get-tags-at (point) t))) > (setq project (nth 4 (org-heading-components)))) > (> (nth 1 (org-heading-components)) 1)))) > project)) > > (with-eval-after-load 'org-agenda > (add-to-list 'org-agenda-prefix-format > '(todo . " %i %?-20(org-get-task-project)"))) > =3D=3D=3D > In the code above we have to make all headings visible first with > org-content because outline-up-heading works only on visible nodes. -- Professor John Kitchin Doherty Hall A207F Department of Chemical Engineering Carnegie Mellon University Pittsburgh, PA 15213 412-268-7803 @johnkitchin http://kitchingroup.cheme.cmu.edu