emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Save-excursion that works with org visibility?
@ 2017-05-14  0:01 Nikolay Kudryavtsev
  2017-05-14  1:05 ` Kyle Meyer
  2017-05-14 12:16 ` John Kitchin
  0 siblings, 2 replies; 5+ messages in thread
From: Nikolay Kudryavtsev @ 2017-05-14  0:01 UTC (permalink / raw)
  To: emacs-orgmode

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-05-14 17:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-14  0:01 Save-excursion that works with org visibility? Nikolay Kudryavtsev
2017-05-14  1:05 ` Kyle Meyer
2017-05-14 16:58   ` Nikolay Kudryavtsev
2017-05-14 12:16 ` John Kitchin
2017-05-14 17:03   ` Nikolay Kudryavtsev

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).