Prechádzať zdrojové kódy

Merge branch 'master' of orgmode.org:org-mode

Bastien Guerry 12 rokov pred
rodič
commit
13c481b583
2 zmenil súbory, kde vykonal 88 pridanie a 55 odobranie
  1. 34 26
      lisp/ox.el
  2. 54 29
      testing/lisp/test-ox.el

+ 34 - 26
lisp/ox.el

@@ -1854,40 +1854,47 @@ export options."
     ignore))
 
 (defun org-export--selected-trees (data info)
-  "Return list of headlines containing a select tag in their tree.
+  "Return list of headlines and inlinetasks with a select tag in their tree.
 DATA is parsed data as returned by `org-element-parse-buffer'.
 INFO is a plist holding export options."
   (let* (selected-trees
-	 walk-data			; for byte-compiler.
+	 walk-data			; For byte-compiler.
 	 (walk-data
 	  (function
 	   (lambda (data genealogy)
-	     (case (org-element-type data)
-	       (org-data (mapc (lambda (el) (funcall walk-data el genealogy))
-			       (org-element-contents data)))
-	       (headline
-		(let ((tags (org-element-property :tags data)))
-		  (if (loop for tag in (plist-get info :select-tags)
-			    thereis (member tag tags))
-		      ;; When a select tag is found, mark full
-		      ;; genealogy and every headline within the tree
-		      ;; as acceptable.
-		      (setq selected-trees
-			    (append
-			     genealogy
-			     (org-element-map data 'headline 'identity)
-			     selected-trees))
-		    ;; Else, continue searching in tree, recursively.
-		    (mapc
-		     (lambda (el) (funcall walk-data el (cons data genealogy)))
-		     (org-element-contents data))))))))))
-    (funcall walk-data data nil) selected-trees))
+	     (let ((type (org-element-type data)))
+	       (cond
+		((memq type '(headline inlinetask))
+		 (let ((tags (org-element-property :tags data)))
+		   (if (loop for tag in (plist-get info :select-tags)
+			     thereis (member tag tags))
+		       ;; When a select tag is found, mark full
+		       ;; genealogy and every headline within the tree
+		       ;; as acceptable.
+		       (setq selected-trees
+			     (append
+			      genealogy
+			      (org-element-map data '(headline inlinetask)
+				'identity)
+			      selected-trees))
+		     ;; If at a headline, continue searching in tree,
+		     ;; recursively.
+		     (when (eq type 'headline)
+		       (mapc (lambda (el)
+			       (funcall walk-data el (cons data genealogy)))
+			     (org-element-contents data))))))
+		((or (eq type 'org-data)
+		     (memq type org-element-greater-elements))
+		 (mapc (lambda (el) (funcall walk-data el genealogy))
+		       (org-element-contents data)))))))))
+    (funcall walk-data data nil)
+    selected-trees))
 
 (defun org-export--skip-p (blob options selected)
   "Non-nil when element or object BLOB should be skipped during export.
 OPTIONS is the plist holding export options.  SELECTED, when
-non-nil, is a list of headlines belonging to a tree with a select
-tag."
+non-nil, is a list of headlines or inlinetasks belonging to
+a tree with a select tag."
   (case (org-element-type blob)
     (clock (not (plist-get options :with-clocks)))
     (drawer
@@ -1902,13 +1909,15 @@ tag."
 		  (if (eq (car with-drawers-p) 'not)
 		      (member-ignore-case name (cdr with-drawers-p))
 		    (not (member-ignore-case name with-drawers-p))))))))
-    (headline
+    ((headline inlinetask)
      (let ((with-tasks (plist-get options :with-tasks))
 	   (todo (org-element-property :todo-keyword blob))
 	   (todo-type (org-element-property :todo-type blob))
 	   (archived (plist-get options :with-archived-trees))
 	   (tags (org-element-property :tags blob)))
        (or
+	(and (eq (org-element-type blob) 'inlinetask)
+	     (not (plist-get options :with-inlinetasks)))
 	;; Ignore subtrees with an exclude tag.
 	(loop for k in (plist-get options :exclude-tags)
 	      thereis (member k tags))
@@ -1925,7 +1934,6 @@ tag."
 		 (and (memq with-tasks '(todo done))
 		      (not (eq todo-type with-tasks)))
 		 (and (consp with-tasks) (not (member todo with-tasks))))))))
-    (inlinetask (not (plist-get options :with-inlinetasks)))
     ((latex-environment latex-fragment) (not (plist-get options :with-latex)))
     (planning (not (plist-get options :with-plannings)))
     (statistics-cookie (not (plist-get options :with-statistics-cookies)))

+ 54 - 29
testing/lisp/test-ox.el

@@ -247,25 +247,19 @@ Paragraph"
 
 (ert-deftest test-org-export/handle-options ()
   "Test if export options have an impact on output."
-  ;; Test exclude tags.
-  (org-test-with-temp-text "* Head1 :noexport:"
-    (org-test-with-backend test
-      (should
-       (equal (org-export-as 'test nil nil nil '(:exclude-tags ("noexport")))
-	      ""))))
-  ;; Test include tags.
-  (org-test-with-temp-text "
-* Head1
-* Head2
-** Sub-Head2.1 :export:
-*** Sub-Head2.1.1
-* Head2"
-    (org-test-with-backend test
-      (should
-       (equal
-	"* Head2\n** Sub-Head2.1 :export:\n*** Sub-Head2.1.1\n"
-	(let ((org-tags-column 0))
-	  (org-export-as 'test nil nil nil '(:select-tags ("export"))))))))
+  ;; Test exclude tags for headlines and inlinetasks.
+  (should
+   (equal ""
+	  (org-test-with-temp-text "* Head1 :noexp:"
+	    (org-test-with-backend test
+	      (org-export-as 'test nil nil nil '(:exclude-tags ("noexp")))))))
+  ;; Test include tags for headlines and inlinetasks.
+  (should
+   (equal "* H2\n** Sub :exp:\n*** Sub Sub\n"
+	  (org-test-with-temp-text "* H1\n* H2\n** Sub :exp:\n*** Sub Sub\n* H3"
+	    (let ((org-tags-column 0))
+	      (org-test-with-backend test
+		(org-export-as 'test nil nil nil '(:select-tags ("exp"))))))))
   ;; Test mixing include tags and exclude tags.
   (org-test-with-temp-text "
 * Head1 :export:
@@ -281,16 +275,18 @@ Paragraph"
 	 'test nil nil nil
 	 '(:select-tags ("export") :exclude-tags ("noexport")))))))
   ;; Ignore tasks.
-  (let ((org-todo-keywords '((sequence "TODO" "DONE"))))
-    (org-test-with-temp-text "* TODO Head1"
-      (org-test-with-backend test
-	(should (equal (org-export-as 'test nil nil nil '(:with-tasks nil))
-		       "")))))
-  (let ((org-todo-keywords '((sequence "TODO" "DONE"))))
-    (org-test-with-temp-text "* TODO Head1"
-      (org-test-with-backend test
-	(should (equal (org-export-as 'test nil nil nil '(:with-tasks t))
-		       "* TODO Head1\n")))))
+  (should
+   (equal ""
+	  (let ((org-todo-keywords '((sequence "TODO" "DONE"))))
+	    (org-test-with-temp-text "* TODO Head1"
+	      (org-test-with-backend test
+		(org-export-as 'test nil nil nil '(:with-tasks nil)))))))
+  (should
+   (equal "* TODO Head1\n"
+	  (let ((org-todo-keywords '((sequence "TODO" "DONE"))))
+	    (org-test-with-temp-text "* TODO Head1"
+	      (org-test-with-backend test
+		(org-export-as 'test nil nil nil '(:with-tasks t)))))))
   ;; Archived tree.
   (org-test-with-temp-text "* Head1 :archive:"
     (let ((org-archive-tag "archive"))
@@ -1230,6 +1226,35 @@ Paragraph[fn:1]"
 	 (lambda (h) (if (org-export-last-sibling-p h info) 'yes 'no))
 	 info))))))
 
+(ert-deftest test-org-export/handle-inlinetasks ()
+  "Test inlinetask export."
+  ;; Inlinetask with an exclude tag.
+  (when (featurep 'org-inlinetask)
+    (should
+     (equal
+      ""
+      (let ((org-inlinetask-min-level 3))
+	(org-test-with-temp-text "*** Inlinetask :noexp:\nContents\n*** end"
+	  (org-test-with-backend test
+	    (org-export-as 'test nil nil nil '(:exclude-tags ("noexp"))))))))
+    ;; Inlinetask with an include tag.
+    (should
+     (equal
+      "* H2\n*** Inline :exp:\n"
+      (let ((org-inlinetask-min-level 3)
+	    (org-tags-column 0))
+	(org-test-with-temp-text "* H1\n* H2\n*** Inline :exp:"
+	  (org-test-with-backend test
+	    (org-export-as 'test nil nil nil '(:select-tags ("exp"))))))))
+    ;; Ignore inlinetask with a TODO keyword and tasks excluded.
+    (should
+     (equal ""
+	    (let ((org-todo-keywords '((sequence "TODO" "DONE")))
+		  (org-inlinetask-min-level 3))
+	      (org-test-with-temp-text "*** TODO Inline"
+		(org-test-with-backend test
+		  (org-export-as 'test nil nil nil '(:with-tasks nil)))))))))
+
 
 
 ;;; Links