8

I would like to be able to have an org-mode file that looks like the following:

* Some Heading     :ignore:noexport:
** Not exported
   Some stuff.
** Other not exported heading
   More stuff.
** Exported        :export:
   Other stuff.

What should get produced when exporting would look like:

Exported
--------

Other Stuff.

The :ignore: tag is used in conjunction with the ox-extra package's ignore-headlines functionality -- see this for details.

It seems that the org-mode file above won't currently export -- is there a workaround that would allow this to work? It seems like the key here would be to make org-mode work so that the presence of an :export: tag removes any inherited :noexport: tag, and vice versa -- the presence of a :noexport: tag should remove an inherited :export: tag for the headline.

2
  • 1
    What level would you want the exported header? As I see it, there might be a problem if it's on the second level, but the first level is not exported. Commented Jun 11, 2016 at 7:17
  • Quoting the manual (info "(org) Export settings"): "When headlines are selectively exported with :export: anywhere in a file, text before the first headline is ignored." In your case, leave out the :noexport: tag since the subheadings not tagged with :export: will be ignored. Changing the export scope to "Subtree" (with <kbd>C-s</kbd>) will lead to the desired result.
    – mutbuerger
    Commented Jun 12, 2016 at 11:08

2 Answers 2

1

You should be able to turn off tag inheritance to get this behaviour, but it's unclear what would happen to the 'orphaned' heading. You can do this using local variables and setting the org-tags-exclude-from-inheritance list.

I don't have access to emacs right now, but the following (untested!) snippet at the start of your org file might do it.

 # -*- mode: org-mode; org-tags-exclude-from-inheritance: '("noexport"); -*-
3
  • I still want the tag of the nearest parent node to be inherited by its children. So I could have, e.g., one subtree whose children inherited :noexport unless explicitly marked as :export:, and other subtrees whose children inherit :export: unless explicitly marked as :noexport:.
    – Mark
    Commented Jun 11, 2016 at 18:11
  • So you want to keep tag inheritance but have the child tag overwrite the meaning of the parent tag? That could be tricky. Commented Jun 11, 2016 at 18:29
  • Yes, that's what I'd like, but I realize it would need to be determined what the export behavior should look like if the parent were not an :ignore: node but had a :noexport: tag, and some of its ancestors had :export: tags -- maybe this reversing-of-the-inherited-tag behavior only makes sense to allow for :ignore: nodes.
    – Mark
    Commented Jun 12, 2016 at 1:38
1

I find it difficult to understand why would want to export a subheading and not export the heading associated to it. But if you have good reasons for doing so may be you can request this feature on the org-mailing list? The option might be add in future releases?

I usually to something like the following

* Some Heading     
** Not exported     :ignore:noexport:
   Some stuff.
** Other not exported heading     :ignore:noexport:
   More stuff.
** Exported        :export:
   Other stuff.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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