emacs-orgmode
[Top][All Lists]
Advanced

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

[O] How to identify all headings that won't be exported?


From: Thomas S. Dye
Subject: [O] How to identify all headings that won't be exported?
Date: Thu, 26 Jun 2014 09:09:44 -1000

Aloha all,

Inspired by John Kitchin's org-ref, I'm working on a little function that
returns all the pieces of an Org mode file that are candidates for cross
referencing. The helm package lets me choose from among the candidates
and then another little function inserts the chosen link.

This all works for me, and I'm finding it really useful.  The only
slight problem is that I haven't been able to figure out how to
eliminate all the headings that won't be exported.  You'll see in the
code below that my simple-minded approach gets all the headings tagged
:noexport:, but it doesn't understand that the tag is inherited by
descendants. Is there a practical way to identify descendants for my use
case? 

  (defun tsd-get-names-labels-and-headings ()
    (interactive)
    (save-excursion
      (goto-char (point-min))
      (let ((matches))
        (while
            (re-search-forward "\\#\\+\\(name\\|label\\):\\s-\\(.*\\)" 
(point-max) t)
          (add-to-list 'matches (match-string-no-properties 2) t))
        (dolist (heading (org-map-entries 'org-heading-components))
          (when (and (nth 4 heading) (not (search "noexport"(nth 5 heading))))
            (add-to-list 'matches (nth 4 heading))))
        (dolist (properties (org-map-entries 'org-entry-properties))
          (when (cdr (assoc "CUSTOM_ID" properties))
            (add-to-list 'matches
                         (format "#%s" (cdr (assoc "CUSTOM_ID" properties))))))
        (sort matches 'string<))))

All the best,
Tom

-- 
Thomas S. Dye
http://www.tsdye.com



reply via email to

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