浏览代码

Allow tags to select parts of a document for export.

Carsten Dominik 16 年之前
父节点
当前提交
ad7e092f98
共有 3 个文件被更改,包括 120 次插入112 次删除
  1. 62 62
      ORGWEBPAGE/Changes.org
  2. 4 0
      lisp/ChangeLog
  3. 54 50
      lisp/org-exp.el

+ 62 - 62
ORGWEBPAGE/Changes.org

@@ -37,7 +37,55 @@
     as a tty key replacement.
 
 ** Details
-*** org-plot.el is now part of Org.
+
+*** Secondary filtering of agenda views.
+
+    You can now easily and interactively filter an existing
+    agenda view with respect to a tag.  This command is executed
+    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 opposite filter is applied: entries that
+    do have the tag will be hidden.
+
+    This operation only hides lines in the agenda buffer.  It
+    does not initiate a new search and therefore is very fast.
+
+    If you press TAB at the tag selection prompt, you will be
+    switched to a completion interface to select a tag.  This is
+    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.
+
+    This functionality was John Wiegley's idea.  It is a simpler
+    implementation of some of the query-editing features proposed
+    and implemented some time ago by Christopher League (see the
+    file contrib/lisp/org-interactive-query.el).
+
+*** Editing fixed-width regions with picture or artist mode
+
+    The command @<code>C-c '@</code> (that is =C-c= followed by a
+    single quote) can now also be used to switch to a special
+    editing mode for fixed-width sections.  The default mode is
+    =artist-mode= which allows you to create ASCII drawings.
+
+    It works like this: Enter the editing mode with
+    @<code>C-c '@</code>.  An indirect buffer will be created and
+    narrowed to the fixed-width region.  Edit the drawing, and
+    press @<code>C-c '@</code> again to exit.
+
+    Lines in a fixed-width region should be preceded by a colon
+    followed by at least one space.  These will be removed during
+    editing, and then added back when you exit the editing mode.
+
+    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.
+*** /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
@@ -69,6 +117,19 @@
 
     This useful feature was a request by Richard G Rigley.
 
+*** New interpretation of prefix arguments when exiting remember
+
+    The prefix argument to the `C-c C-c' command that finishes a
+    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
+    :C-0 C-c C-c   Re-use the last used location
+    :C-u C-c C-c   Like C-c C-c, but immediately visit the note
+    :              in its new location.
+
+    This was requested by John Wiegley.
+
 *** Yanking inserts folded subtrees
 
     If the kill is a subtree or a sequence of subtrees, yanking
@@ -101,67 +162,6 @@
     
     This was a request by Peter Frings.
 
-*** Secondary filtering of agenda views.
-
-    You can now easily and interactively filter an existing
-    agenda view with respect to a tag.  This command is executed
-    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 opposite filter is applied: entries that
-    do have the tag will be hidden.
-
-    This operation only hides lines in the agenda buffer.  It
-    does not initiate a new search and therefore is very fast.
-
-    If you press TAB at the tag selection prompt, you will be
-    switched to a completion interface to select a tag.  This is
-    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.
-
-    This functionality was John Wiegley's idea.  It is a simpler
-    implementation of some of the query-editing features proposed
-    and implemented some time ago by Christopher League (see the
-    file contrib/lisp/org-interactive-query.el).
-
-*** Editing fixed-width regions with picture or artist mode
-
-    The command @<code>C-c '@</code> (that is =C-c= followed by a
-    single quote) can now also be used to switch to a special
-    editing mode for fixed-width sections.  The default mode is
-    =artist-mode= which allows you to create ASCII drawings.
-
-    It works like this: Enter the editing mode with
-    @<code>C-c '@</code>.  An indirect buffer will be created and
-    narrowed to the fixed-width region.  Edit the drawing, and
-    press @<code>C-c '@</code> again to exit.
-
-    Lines in a fixed-width region should be preceded by a colon
-    followed by at least one space.  These will be removed during
-    editing, and then added back when you exit the editing mode.
-
-    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 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
-    :C-0 C-c C-c   Re-use the last used location
-    :C-u C-c C-c   Like C-c C-c, but immediately visit the note
-    :              in its new location.
-
-    This was requested by John Wiegley.
-
 *** Sorting entries now ignores the TODO keyword and the priority
 
     Numerical and alphanumerical sorting now skips any TODO

+ 4 - 0
lisp/ChangeLog

@@ -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.

+ 54 - 50
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