emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* How to identify all headings that won't be exported?
@ 2014-06-26 19:09 Thomas S. Dye
  2014-06-27  0:40 ` Thomas S. Dye
       [not found] ` <CAEWDx5f+MgsCFFw9h9hoPT_HcKstt4WG6s+FZKRzEEH3G1So_A@mail.gmail.com>
  0 siblings, 2 replies; 3+ messages in thread
From: Thomas S. Dye @ 2014-06-26 19:09 UTC (permalink / raw)
  To: Org-mode

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

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

end of thread, other threads:[~2014-06-27  0:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-26 19:09 How to identify all headings that won't be exported? Thomas S. Dye
2014-06-27  0:40 ` Thomas S. Dye
     [not found] ` <CAEWDx5f+MgsCFFw9h9hoPT_HcKstt4WG6s+FZKRzEEH3G1So_A@mail.gmail.com>
2014-06-27  0:59   ` Fwd: " Jonathan Leech-Pepin

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).