From: tsd@tsdye.com (Thomas S. Dye)
To: Org-mode <emacs-orgmode@gnu.org>
Subject: How to identify all headings that won't be exported?
Date: Thu, 26 Jun 2014 09:09:44 -1000 [thread overview]
Message-ID: <m2k383o5c7.fsf@tsdye.com> (raw)
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
next reply other threads:[~2014-06-26 19:10 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-26 19:09 Thomas S. Dye [this message]
2014-06-27 0:40 ` How to identify all headings that won't be exported? Thomas S. Dye
[not found] ` <CAEWDx5f+MgsCFFw9h9hoPT_HcKstt4WG6s+FZKRzEEH3G1So_A@mail.gmail.com>
2014-06-27 0:59 ` Fwd: " Jonathan Leech-Pepin
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=m2k383o5c7.fsf@tsdye.com \
--to=tsd@tsdye.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).