emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Jonathan Leech-Pepin <jonathan.leechpepin@gmail.com>
To: Org Mode Mailing List <emacs-orgmode@gnu.org>
Subject: Fwd: Re: How to identify all headings that won't be exported?
Date: Thu, 26 Jun 2014 20:59:11 -0400	[thread overview]
Message-ID: <CAEWDx5cc+_S3_OPfgW__+r+-3Fv9FjWm0RmUDWh0fT9U+Xz0=w@mail.gmail.com> (raw)
In-Reply-To: <CAEWDx5f+MgsCFFw9h9hoPT_HcKstt4WG6s+FZKRzEEH3G1So_A@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2755 bytes --]

Forwarding to list. Somehow reply-all did not actually reply to all
---------- Forwarded message ----------
From: "Jonathan Leech-Pepin" <jonathan.leechpepin@gmail.com>
Date: Jun 26, 2014 4:05 PM
Subject: Re: [O] How to identify all headings that won't be exported?
To: "Thomas S. Dye" <tsd@tsdye.com>
Cc:

Hello Thomas


On 26 June 2014 15:09, Thomas S. Dye <tsd@tsdye.com> wrote:

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

For the matching portion itself the following should work:

(org-map-entries (lambda () (org-element-property :raw-value
(org-element-at-point))) (format "-%s" (mapconcat 'identity
org-export-exclude-tags "-")))

Rather than try and search for the tag afterwards, create a string that
will match all non-exporting tags and have them excluded from the match
itself (by default this will be "-noexport" but if you add "test" it will
become "-noexport-test").  It also gives you the exact raw value of the
element.  Using just 'org-element-at-point would give you the entire
element, allowing you to display the :raw-value in your output but also
have the associated :begin to jump to, removing the need to search for the
headline again later on.




> All the best,
> Tom
>
> --
> Thomas S. Dye
> http://www.tsdye.com
>
>

[-- Attachment #2: Type: text/html, Size: 3941 bytes --]

      parent reply	other threads:[~2014-06-27  0:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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   ` Jonathan Leech-Pepin [this message]

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='CAEWDx5cc+_S3_OPfgW__+r+-3Fv9FjWm0RmUDWh0fT9U+Xz0=w@mail.gmail.com' \
    --to=jonathan.leechpepin@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).