Allow tags to select parts of a document for export.
This commit is contained in:
parent
951a80987b
commit
ad7e092f98
|
@ -37,69 +37,6 @@
|
|||
as a tty key replacement.
|
||||
|
||||
** Details
|
||||
*** org-plot.el is now part of Org.
|
||||
|
||||
You can run it by simple calling org-plot/gnuplot.
|
||||
Documentation is not yet included with Org, please refer to
|
||||
http://github.com/eschulte/org-plot/tree/master until we have
|
||||
moved the docs into Org or Worg.
|
||||
|
||||
Thanks to Eric Schulte for this great contribution.
|
||||
|
||||
*** Tags can be used to select the export part of a document
|
||||
|
||||
You may now use tags to select parts of a document for
|
||||
inclusion into the export, and to exclude other parts. This
|
||||
behavior is governed by two new variables:
|
||||
=org-export-select-tags= and =org-export-exclude-tags=.
|
||||
These default to =("export")= and =("noexport")=, but can be
|
||||
changed, even to include a list of several tags.
|
||||
|
||||
Org first checks if any of the /select/ tags is present in
|
||||
the buffer. All trees that do not carry one of these tags
|
||||
will be excluded. If a selected tree is a subtree, the
|
||||
heading hierarchy above it will also be selected for export,
|
||||
but not the text below those headings. If none of the select
|
||||
tags is found, the whole buffer will be selected for export.
|
||||
Finally, all subtrees that are marked by any of the /exclude/
|
||||
tags will be removed from the export buffer.
|
||||
|
||||
You may set these tags with inbuffer-options
|
||||
=EXPORT_SELECT_TAGS= and =EXPORT_EXCLUDE_TAGS=.
|
||||
|
||||
This useful feature was a request by Richard G Rigley.
|
||||
|
||||
*** Yanking inserts folded subtrees
|
||||
|
||||
If the kill is a subtree or a sequence of subtrees, yanking
|
||||
them with =C-y= will leave all the subtrees in a folded
|
||||
state. This basically means, that kill and yank are now
|
||||
much more useful in moving stuff around in your outline. If
|
||||
you do not like this, customize the variable
|
||||
=org-yank-folded-subtrees=.
|
||||
|
||||
Right now, I am only binding =C-y= to this new function,
|
||||
should I modify all bindings of yank? Do we need to amend
|
||||
=yank-pop= as well?
|
||||
|
||||
This feature was requested by John Wiegley.
|
||||
|
||||
*** Prefix arg 0 to S-RET disables integer increment during copy
|
||||
|
||||
This was a request by Chris Randle.
|
||||
|
||||
*** Column view capture tables can have formulas, plotting info
|
||||
|
||||
If you attach formulas and plotting instructions to a table
|
||||
capturing column view, these extra lines will now survive an
|
||||
update of the column view capture, and any formulas will be
|
||||
re-applied to the captured table. This works be keeping any
|
||||
continuous block of comments before and after the actual
|
||||
table.
|
||||
|
||||
*** The note buffer for clocking out now mentions the task
|
||||
|
||||
This was a request by Peter Frings.
|
||||
|
||||
*** Secondary filtering of agenda views.
|
||||
|
||||
|
@ -148,6 +85,37 @@
|
|||
|
||||
This exciting new feature arose from a discussion involving
|
||||
Scott Otterson, Sebastian Rose and Will Henney.
|
||||
*** /org-plot.el/ is now part of Org.
|
||||
|
||||
You can run it by simple calling org-plot/gnuplot.
|
||||
Documentation is not yet included with Org, please refer to
|
||||
http://github.com/eschulte/org-plot/tree/master until we have
|
||||
moved the docs into Org or Worg.
|
||||
|
||||
Thanks to Eric Schulte for this great contribution.
|
||||
|
||||
*** Tags can be used to select the export part of a document
|
||||
|
||||
You may now use tags to select parts of a document for
|
||||
inclusion into the export, and to exclude other parts. This
|
||||
behavior is governed by two new variables:
|
||||
=org-export-select-tags= and =org-export-exclude-tags=.
|
||||
These default to =("export")= and =("noexport")=, but can be
|
||||
changed, even to include a list of several tags.
|
||||
|
||||
Org first checks if any of the /select/ tags is present in
|
||||
the buffer. All trees that do not carry one of these tags
|
||||
will be excluded. If a selected tree is a subtree, the
|
||||
heading hierarchy above it will also be selected for export,
|
||||
but not the text below those headings. If none of the select
|
||||
tags is found, the whole buffer will be selected for export.
|
||||
Finally, all subtrees that are marked by any of the /exclude/
|
||||
tags will be removed from the export buffer.
|
||||
|
||||
You may set these tags with inbuffer-options
|
||||
=EXPORT_SELECT_TAGS= and =EXPORT_EXCLUDE_TAGS=.
|
||||
|
||||
This useful feature was a request by Richard G Rigley.
|
||||
|
||||
*** New interpretation of prefix arguments when exiting remember
|
||||
|
||||
|
@ -162,6 +130,38 @@
|
|||
|
||||
This was requested by John Wiegley.
|
||||
|
||||
*** Yanking inserts folded subtrees
|
||||
|
||||
If the kill is a subtree or a sequence of subtrees, yanking
|
||||
them with =C-y= will leave all the subtrees in a folded
|
||||
state. This basically means, that kill and yank are now
|
||||
much more useful in moving stuff around in your outline. If
|
||||
you do not like this, customize the variable
|
||||
=org-yank-folded-subtrees=.
|
||||
|
||||
Right now, I am only binding =C-y= to this new function,
|
||||
should I modify all bindings of yank? Do we need to amend
|
||||
=yank-pop= as well?
|
||||
|
||||
This feature was requested by John Wiegley.
|
||||
|
||||
*** Prefix arg 0 to S-RET disables integer increment during copy
|
||||
|
||||
This was a request by Chris Randle.
|
||||
|
||||
*** Column view capture tables can have formulas, plotting info
|
||||
|
||||
If you attach formulas and plotting instructions to a table
|
||||
capturing column view, these extra lines will now survive an
|
||||
update of the column view capture, and any formulas will be
|
||||
re-applied to the captured table. This works be keeping any
|
||||
continuous block of comments before and after the actual
|
||||
table.
|
||||
|
||||
*** The note buffer for clocking out now mentions the task
|
||||
|
||||
This was a request by Peter Frings.
|
||||
|
||||
*** Sorting entries now ignores the TODO keyword and the priority
|
||||
|
||||
Numerical and alphanumerical sorting now skips any TODO
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
2008-09-17 Carsten Dominik <dominik@science.uva.nl>
|
||||
|
||||
* org-exp.el (org-export-handle-export-tags): New function.
|
||||
(org-export-preprocess-string): Call
|
||||
`org-export-handle-export-tags'.
|
||||
|
||||
* org-plot.el: New file.
|
||||
|
||||
* org-publish.el (org-publish-expand-components): Function removed.
|
||||
|
|
104
lisp/org-exp.el
104
lisp/org-exp.el
|
@ -1565,6 +1565,60 @@ whose content to keep."
|
|||
(while (re-search-forward re nil t)
|
||||
(replace-match "")))))
|
||||
|
||||
(defun org-export-handle-export-tags (select-tags exclude-tags)
|
||||
"Modify the buffer, honoring SELECT-TAGS and EXCLUDE-TAGS.
|
||||
Both arguments are lists of tags.
|
||||
If any of SELECT-TAGS is found, all trees not marked by a SELECT-TAG
|
||||
will be removed.
|
||||
After that, all subtrees that are marked by EXCLUDE-TAGS will be
|
||||
removed as well."
|
||||
(remove-text-properties (point-min) (point-max) '(:org-delete t))
|
||||
(let* ((re-sel (concat ":\\(" (mapconcat 'regexp-quote
|
||||
select-tags "\\|")
|
||||
"\\):"))
|
||||
(re-excl (concat ":\\(" (mapconcat 'regexp-quote
|
||||
exclude-tags "\\|")
|
||||
"\\):"))
|
||||
beg end)
|
||||
(goto-char (point-min))
|
||||
(when (and select-tags
|
||||
(re-search-forward
|
||||
(concat "^\\*+[ \t].*" re-sel "[^ \t\n]*[ \t]*$") nil t))
|
||||
;; At least one tree is marked for export, this means
|
||||
;; all the unmarked stuff needs to go.
|
||||
;; Dig out the trees that should be exported
|
||||
(goto-char (point-min))
|
||||
(outline-next-heading)
|
||||
(setq beg (point))
|
||||
(put-text-property beg (point-max) :org-delete t)
|
||||
(while (re-search-forward re-sel nil t)
|
||||
(when (org-on-heading-p)
|
||||
(org-back-to-heading)
|
||||
(remove-text-properties
|
||||
(max (1- (point)) (point-min))
|
||||
(setq cont (save-excursion (org-end-of-subtree t t)))
|
||||
'(:org-delete t))
|
||||
(while (and (org-up-heading-safe)
|
||||
(get-text-property (point) :org-delete))
|
||||
(remove-text-properties (max (1- (point)) (point-min))
|
||||
(point-at-eol) '(:org-delete t)))
|
||||
(goto-char cont))))
|
||||
;; Remove the trees explicitly marked for noexport
|
||||
(when exclude-tags
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward re-excl nil t)
|
||||
(when (org-at-heading-p)
|
||||
(org-back-to-heading t)
|
||||
(setq beg (point))
|
||||
(org-end-of-subtree t)
|
||||
(delete-region beg (point)))))
|
||||
;; Remove everything that is now still marked for deletion
|
||||
(goto-char (point-min))
|
||||
(while (setq beg (text-property-any (point-min) (point-max) :org-delete t))
|
||||
(setq end (or (next-single-property-change beg :org-delete)
|
||||
(point-max)))
|
||||
(delete-region beg end))))
|
||||
|
||||
(defun org-export-remove-archived-trees (export-archived-trees)
|
||||
"Remove archived trees.
|
||||
When EXPORT-ARCHIVED-TREES is `headline;, only the headline will be exported.
|
||||
|
@ -4477,56 +4531,6 @@ This is without contition, so even subtrees inside that carry one of the
|
|||
:group 'org-export
|
||||
:type '(repeat (string :tag "Tag")))
|
||||
|
||||
(defun org-export-handle-export-tags (select-tags exclude-tags)
|
||||
(interactive)
|
||||
(debug)
|
||||
(remove-text-properties (point-min) (point-max) '(:org-delete t))
|
||||
(let* ((re-sel (concat ":\\(" (mapconcat 'regexp-quote
|
||||
select-tags "\\|")
|
||||
"\\):"))
|
||||
(re-excl (concat ":\\(" (mapconcat 'regexp-quote
|
||||
exclude-tags "\\|")
|
||||
"\\):"))
|
||||
beg end)
|
||||
(goto-char (point-min))
|
||||
(when (and select-tags
|
||||
(re-search-forward
|
||||
(concat "^\\*+[ \t].*" re-sel "[^ \t\n]*[ \t]*$") nil t))
|
||||
;; At least one tree is marked for export, this means
|
||||
;; all the unmarked stuff needs to go.
|
||||
;; Dig out the trees that should be exported
|
||||
(goto-char (point-min))
|
||||
(outline-next-heading)
|
||||
(setq beg (point))
|
||||
(put-text-property beg (point-max) :org-delete t)
|
||||
(while (re-search-forward re-sel nil t)
|
||||
(when (org-on-heading-p)
|
||||
(org-back-to-heading)
|
||||
(remove-text-properties
|
||||
(max (1- (point)) (point-min))
|
||||
(setq cont (save-excursion (org-end-of-subtree t t)))
|
||||
'(:org-delete t))
|
||||
(while (and (org-up-heading-safe)
|
||||
(get-text-property (point) :org-delete))
|
||||
(remove-text-properties (max (1- (point)) (point-min))
|
||||
(point-at-eol) '(:org-delete t)))
|
||||
(goto-char cont))))
|
||||
;; Remove the trees explicitly marked for noexport
|
||||
(when exclude-tags
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward re-excl nil t)
|
||||
(when (org-at-heading-p)
|
||||
(org-back-to-heading t)
|
||||
(setq beg (point))
|
||||
(org-end-of-subtree t)
|
||||
(delete-region beg (point)))))
|
||||
;; Remove everything that is now still marked for deletion
|
||||
(goto-char (point-min))
|
||||
(while (setq beg (text-property-any (point-min) (point-max) :org-delete t))
|
||||
(setq end (or (next-single-property-change beg :org-delete)
|
||||
(point-max)))
|
||||
(delete-region beg end))))
|
||||
|
||||
;; arch-tag: 65985fe9-095c-49c7-a7b6-cb4ee15c0a95
|
||||
|
||||
;;; org-exp.el ends here
|
||||
|
|
Loading…
Reference in New Issue