emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] Save-excursion that works with org visibility?


From: Nikolay Kudryavtsev
Subject: [O] Save-excursion that works with org visibility?
Date: Sun, 14 May 2017 03:01:07 +0300
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]