From 8e2b65bdef3b06d4fff812b843831989dc84b174 Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Tue, 16 Sep 2008 16:52:21 +0200 Subject: [PATCH] Intermediate --- ORGWEBPAGE/Changes.org | 61 +++++++++++++++++++++----- doc/org.texi | 41 ++++++++++++++++-- lisp/org-exp.el | 93 ++++++++++++++++++++++++++++++++++++++-- lisp/org-export-latex.el | 2 + 4 files changed, 180 insertions(+), 17 deletions(-) diff --git a/ORGWEBPAGE/Changes.org b/ORGWEBPAGE/Changes.org index aea74dffe..ab8b1367a 100644 --- a/ORGWEBPAGE/Changes.org +++ b/ORGWEBPAGE/Changes.org @@ -18,8 +18,9 @@ ** Incompatible changes *** Prefix interpretation when storing remember notes + The prefix argument to the `C-c C-c' command that finishes a - remember process is not interpetred differently: + remember process is now interpreted differently: :C-c C-c Store the note to predefined file and headline :C-1 C-c C-c Select the storage location interactively @@ -31,10 +32,35 @@ *** Capturing column view is now on `C-c C-x i' + The reason for this change was that `C-c C-x r' is also used as a tty key replacement. + ** Details +*** 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 @@ -50,14 +76,18 @@ This feature was requested by John Wiegley. -*** Prefix arg 0 to S-RET disabled integer increment during copy +*** 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 and plotting instructions + +*** 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 coloumn view capture, and any formulas will be + 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 bfore an after the actual table. + continuous block of comments before and after the actual + table. *** The note buffer for clocking out now mentions the task @@ -70,7 +100,7 @@ with the =/= key in the agenda. You will be prompted for a tag selection key, and all entries that do not contain or inherit the corresponding tag will be hidden. With a prefix - argument, the complementary filter is applied: entries that + argument, the opposite filter is applied: entries that do have the tag will be hidden. This operation only hides lines in the agenda buffer. It @@ -78,8 +108,8 @@ If you press TAB at the tag selection prompt, you will be switched to a completion interface to select a tag. This is - useful in particular when you want to select a tag that does - not have a direct access character. + useful when you want to select a tag that does not have a + direct access character. A double =/ /= will restore the original agenda view by unhiding any hidden lines. @@ -108,9 +138,13 @@ Using the command in an empty line will create a new fixed-width region. + This exciting new feature arose from a discussion involving + Scott Otterson, Sebastian Rose and Will Henney. + *** New interpretation of prefix arguments when exiting remember + The prefix argument to the `C-c C-c' command that finishes a - remember process is not interpetred differently: + remember process is now interpreted differently: :C-c C-c Store the note to predefined file and headline :C-1 C-c C-c Select the storage location interactively @@ -121,18 +155,25 @@ This was requested by John Wiegley. *** Sorting entries now ignores the TODO keyword and the priority + Numerical and alphanumerical sorting now skips any TODO keyword or priority cookie when constructing the comparison string. This was a request by Wanrong Lin. -*** New face =org-scheduled= for entries that at some time in the future. +*** New face =org-scheduled= for entries scheduled in the future. + This was a request by Richard G Rigley. + *** Remember templates for gnus links can now use the :to escape. + Thanks to Tommy Lindgren for a patch to this effect. + *** The file specification in a remember template may now be a function + Thanks to Gregory Sullivan for a patch to this effect. *** It is now possible to define filters for column view + The filter can modify the value that will be displayed in a column, for example it can cut out a part of a time stamp. For more information, look at the variable diff --git a/doc/org.texi b/doc/org.texi index f7902cdf8..764a6a1b5 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -280,6 +280,7 @@ Embedded LaTeX Exporting * Markup rules:: Which structures are recognized? +* Selective export:: Using tags to select and exclude trees * Export options:: Per-file export settings * The export dispatcher:: How to access exporter commands * ASCII export:: Exporting to plain ASCII @@ -4106,8 +4107,8 @@ you have several clock table blocks in a buffer. You can add formulas to the column view table and you may add plotting instructions in front of the table - these will survive an update of the -block. If there is a @code{#+TBLFM:} after the table, the table will actually -be recalculated automatically after an update. +block. If there is a @code{#+TBLFM:} after the table, the table will +actually be recalculated automatically after an update. @node Property API, , Column view, Properties and Columns @section The Property API @@ -6743,6 +6744,7 @@ Org mode only supports export, not import of these different formats. @menu * Markup rules:: Which structures are recognized? +* Selective export:: Using tags to select and exclude trees * Export options:: Per-file export settings * The export dispatcher:: How to access exporter commands * ASCII export:: Exporting to plain ASCII @@ -6752,7 +6754,7 @@ Org mode only supports export, not import of these different formats. * iCalendar export:: Exporting in iCalendar format @end menu -@node Markup rules, Export options, Exporting, Exporting +@node Markup rules, Selective export, Exporting, Exporting @section Markup rules When exporting Org mode documents, the exporter tries to reflect the @@ -7076,7 +7078,28 @@ never be exported. Also entire subtrees starting with the word Toggle the COMMENT keyword at the beginning of an entry. @end table -@node Export options, The export dispatcher, Markup rules, Exporting +@node Selective export, Export options, Markup rules, Exporting +@section Selective export +@cindex export, selective by tags + +You may use tags to select the parts of a document that should be exported, +or to exclude parts from export. This behavior is governed by two variables: +@code{org-export-select-tags} and @code{org-export-exclude-tags}. + +Org first checks if any of the @emph{select} tags is present in the buffer. +If yes, 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. + +@noindent +If none of the select tags is found, the whole buffer will be selected for +export. + +@noindent +Finally, all subtrees that are marked by any of the @emph{exclude} tags will +be removed from the export buffer. + +@node Export options, The export dispatcher, Selective export, Exporting @section Export options @cindex options, for export @@ -7103,6 +7126,8 @@ Insert template with export options, see example below. @cindex #+OPTIONS: @cindex #+LINK_UP: @cindex #+LINK_HOME: +@cindex #+EXPORT_SELECT_TAGS: +@cindex #+EXPORT_EXCLUDE_TAGS: @example #+TITLE: the title to be shown (default is the buffer name) #+AUTHOR: the author (default taken from @code{user-full-name}) @@ -7114,6 +7139,8 @@ Insert template with export options, see example below. #+OPTIONS: H:2 num:t toc:t \n:nil @@:t ::t |:t ^:t f:t TeX:t ... #+LINK_UP: the ``up'' link of an exported page #+LINK_HOME: the ``home'' link of an exported page +#+EXPORT_SELECT_TAGS: Tags that select a tree for export +#+EXPORT_EXCLUDE_TAGS: Tags that exclude a tree from export @end example @noindent @@ -7845,6 +7872,8 @@ respective variable for details. @item @code{:auto-postamble} @tab @code{org-export-html-auto-postamble} @item @code{:author} @tab @code{user-full-name} @item @code{:email} @tab @code{user-mail-address} +@item @code{:select-tags} @tab @code{org-export-select-tags} +@item @code{:exclude-tags} @tab @code{org-export-exclude-tags} @end multitable If you use several email addresses, separate them by a semi-column. @@ -8689,6 +8718,8 @@ distribution, others are available somewhere on the web. to publish the same file using either org-publish or Muse. @item @file{org-panel.el} by @i{Lennard Borgman} Simplified and display-aided access to some Org commands. +@c @item @file{org-plot.el} by @i{Eric Schulte} +@c Plotting Org tables with Gnuplot. @item @file{org-registry.el} by @i{Bastien Guerry} A registry for Org links, to find out from where links point to a given file or location. @@ -9609,6 +9640,8 @@ of feedback, developed and applied standards to the Org documentation. @i{Christian Schlauer} proposed angular brackets around links, among other things. @item +@i{Eric Schulte} wrote @file{org-plot.el}. +@item Linking to VM/BBDB/Gnus was first inspired by @i{Tom Shannon}'s @file{organizer-mode.el}. @item diff --git a/lisp/org-exp.el b/lisp/org-exp.el index 15c92ba80..eb9f3def3 100644 --- a/lisp/org-exp.el +++ b/lisp/org-exp.el @@ -793,7 +793,9 @@ or if they are only using it locally." (:auto-preamble . org-export-html-auto-preamble) (:auto-postamble . org-export-html-auto-postamble) (:author . user-full-name) - (:email . user-mail-address))) + (:email . user-mail-address) + (:select-tags . org-export-select-tags) + (:exclude-tags . org-export-exclude-tags))) (defun org-default-export-plist () "Return the property list with default settings for the export variables." @@ -829,7 +831,8 @@ modified) list.") (let ((re (org-make-options-regexp (append '("TITLE" "AUTHOR" "DATE" "EMAIL" "TEXT" "OPTIONS" "LANGUAGE" - "LINK_UP" "LINK_HOME" "SETUPFILE" "STYLE") + "LINK_UP" "LINK_HOME" "SETUPFILE" "STYLE" + "EXPORT_SELECT_TAGS" "EXPORT_EXCLUDE_TAGS") (mapcar 'car org-export-inbuffer-options-extra)))) p key val text options js-up js-main js-css js-opt a pr ext-setup-or-nil setup-contents (start 0)) @@ -858,6 +861,10 @@ modified) list.") (setq p (plist-put p :link-up val))) ((string-equal key "LINK_HOME") (setq p (plist-put p :link-home val))) + ((string-equal key "EXPORT_SELECT_TAGS") + (setq p (plist-put p :select-tags (org-split-string val)))) + ((string-equal key "EXPORT_EXCLUDE_TAGS") + (setq p (plist-put p :exclude-tags (org-split-string val)))) ((equal key "SETUPFILE") (setq setup-contents (org-file-contents (expand-file-name @@ -1357,6 +1364,10 @@ on this string to produce the exported version." ;; Handle include files (org-export-handle-include-files) + ;; Get rid of excluded trees + (org-export-handle-export-tags (plist-get parameters :select-tags) + (plist-get parameters :exclude-tags)) + ;; Handle source code snippets (org-export-replace-src-segments) @@ -2113,6 +2124,8 @@ underlined headlines. The default is 3." (plist-get opt-plist :skip-before-1st-heading) :drawers (plist-get opt-plist :drawers) :verbatim-multiline t + :select-tags (plist-get opt-plist :select-tags) + :exclude-tags (plist-get opt-plist :exclude-tags) :archived-trees (plist-get opt-plist :archived-trees) :add-text (plist-get opt-plist :text)) @@ -2474,6 +2487,8 @@ Does include HTML export options as well as TODO and CATEGORY stuff." #+LANGUAGE: %s #+OPTIONS: H:%d num:%s toc:%s \\n:%s @:%s ::%s |:%s ^:%s -:%s f:%s *:%s TeX:%s LaTeX:%s skip:%s d:%s tags:%s %s +#+EXPORT_SELECT_TAGS: %s +#+EXPORT_EXCUDE_TAGS: %s #+LINK_UP: %s #+LINK_HOME: %s #+CATEGORY: %s @@ -2507,6 +2522,8 @@ Does include HTML export options as well as TODO and CATEGORY stuff." org-export-with-drawers org-export-with-tags (if (featurep 'org-jsinfo) (org-infojs-options-inbuffer-template) "") + (mapconcat 'identity org-export-select-tags " ") + (mapconcat 'identity org-export-exclude-tags " ") org-export-html-link-up org-export-html-link-home (file-name-nondirectory buffer-file-name) @@ -2777,6 +2794,8 @@ PUB-DIR is set, use this as the publishing directory." :drawers (plist-get opt-plist :drawers) :archived-trees (plist-get opt-plist :archived-trees) + :select-tags (plist-get opt-plist :select-tags) + :exclude-tags (plist-get opt-plist :exclude-tags) :add-text (plist-get opt-plist :text) :LaTeX-fragments @@ -3316,7 +3335,7 @@ lang=\"%s\" xml:lang=\"%s\"> (org-html-level-start 1 nil umax (and org-export-with-toc (<= level umax)) head-count) - ;; the to lose the last text-... div. + ;; the to close the last text-... div. (insert "\n") (unless body-only @@ -4440,6 +4459,74 @@ The XOXO buffer is named *xoxo-*" (provide 'org-exp) + +(defcustom org-export-select-tags '("export") + "Tags that select a tree for export. +If any such tag is found in a buffer, all trees that do not carry one +of these tags will be deleted before export. +Inside trees that are selected like this, you can still deselect a +subtree by tagging it with one of the `org-export-excude-tags'." + :group 'org-export + :type '(repeat (string :tag "Tag"))) + +(defcustom org-export-exclude-tags '("noexport") + "Tags that exclude a tree from export. +All trees carrying any of these tags will be excluded from export. +This is without contition, so even subtrees inside that carry one of the +`org-export-select-tags' will be removed." + :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 diff --git a/lisp/org-export-latex.el b/lisp/org-export-latex.el index d6661c0ac..4dcaa0458 100644 --- a/lisp/org-export-latex.el +++ b/lisp/org-export-latex.el @@ -429,6 +429,8 @@ when PUB-DIR is set, use this as the publishing directory." :comments nil :add-text (if (eq to-buffer 'string) nil text) :skip-before-1st-heading skip + :select-tags (plist-get opt-plist :select-tags) + :exclude-tags (plist-get opt-plist :exclude-tags) :LaTeX-fragments nil))) (set-buffer buffer)