2

Suppose I'm at point Grandchild below:

* Parent                                                           :@Project:
** Child
**** Grandchild

How can I construct an elisp function that goes up the hierarchy until it finds the first org header that directly has the @Project tag, and returns its name (i.e., in this case "Parent")?

5

Here's a function that does that:

(defun get-parent ()
  (save-excursion
    (catch 'found
      (while (org-up-heading-safe)
        (when (and (member "@Project" (org-get-tags nil t))
                   (looking-at org-complex-heading-regexp))
          (throw 'found (match-string-no-properties 4)))))))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.