emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nikolay Kudryavtsev <nikolay.kudryavtsev@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Save-excursion that works with org visibility?
Date: Sun, 14 May 2017 03:01:07 +0300	[thread overview]
Message-ID: <a8b69f8f-ed8a-bebf-cc20-e77aa637220b@gmail.com> (raw)

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	other threads:[~2017-05-14  0:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-14  0:01 Nikolay Kudryavtsev [this message]
2017-05-14  1:05 ` Save-excursion that works with org visibility? Kyle Meyer
2017-05-14 16:58   ` Nikolay Kudryavtsev
2017-05-14 12:16 ` John Kitchin
2017-05-14 17:03   ` Nikolay Kudryavtsev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a8b69f8f-ed8a-bebf-cc20-e77aa637220b@gmail.com \
    --to=nikolay.kudryavtsev@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).