From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nikolay Kudryavtsev Subject: Save-excursion that works with org visibility? Date: Sun, 14 May 2017 03:01:07 +0300 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:47231) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d9gyI-0004qD-0N for emacs-orgmode@gnu.org; Sat, 13 May 2017 20:01:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d9gyE-0003wl-Uf for emacs-orgmode@gnu.org; Sat, 13 May 2017 20:01:14 -0400 Received: from mail-lf0-x22d.google.com ([2a00:1450:4010:c07::22d]:33684) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d9gyE-0003wM-NA for emacs-orgmode@gnu.org; Sat, 13 May 2017 20:01:10 -0400 Received: by mail-lf0-x22d.google.com with SMTP id m18so8316268lfj.0 for ; Sat, 13 May 2017 17:01:09 -0700 (PDT) Received: from [192.168.199.3] (broadband-95-84-209-126.moscow.rt.ru. [95.84.209.126]) by smtp.gmail.com with ESMTPSA id 75sm1363699lja.53.2017.05.13.17.01.06 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 13 May 2017 17:01:06 -0700 (PDT) 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: emacs-orgmode@gnu.org 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 ะก 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: === (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)"))) === In the code above we have to make all headings visible first with org-content because outline-up-heading works only on visible nodes. -- Best Regards, Nikolay Kudryavtsev