summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <n.goaziou@gmail.com>2012-05-26 13:44:13 +0200
committerNicolas Goaziou <n.goaziou@gmail.com>2012-05-26 13:52:03 +0200
commit09164e5c723d3df4919fc70cf146add75dab2147 (patch)
treeb675f91cb9b166b3122669d47e7473d9c6f48dc4
parent68744bf19f58c52ad984d1a36cedc5573bb112e8 (diff)
downloadorg-mode-09164e5c723d3df4919fc70cf146add75dab2147.tar.gz
org-export: Hide select tags
* contrib/lisp/org-export.el (org-export-get-tags): New function. * contrib/lisp/org-e-ascii.el (org-e-ascii--build-title): Use new function. * contrib/lisp/org-e-html.el (org-e-html-format-headline--wrap, org-e-html-headline): Use new function. * contrib/lisp/org-e-latex.el (org-e-latex-headline, org-e-latex-inlinetask): Use new function. * contrib/lisp/org-e-odt.el (org-e-odt-format-headline--wrap): Use new function. * testing/lisp/test-org-export.el: Add tests.
-rw-r--r--contrib/lisp/org-e-ascii.el2
-rw-r--r--contrib/lisp/org-e-html.el4
-rw-r--r--contrib/lisp/org-e-latex.el4
-rw-r--r--contrib/lisp/org-e-odt.el2
-rw-r--r--contrib/lisp/org-export.el16
-rw-r--r--testing/lisp/test-org-export.el44
6 files changed, 62 insertions, 10 deletions
diff --git a/contrib/lisp/org-e-ascii.el b/contrib/lisp/org-e-ascii.el
index 654f688..c8bc334 100644
--- a/contrib/lisp/org-e-ascii.el
+++ b/contrib/lisp/org-e-ascii.el
@@ -649,7 +649,7 @@ title."
(and todo (concat (org-export-data todo info) " ")))))
(tags (and (not notags)
(plist-get info :with-tags)
- (let ((tag-list (org-element-property :tags element)))
+ (let ((tag-list (org-export-get-tags element info)))
(and tag-list
(format ":%s:"
(mapconcat 'identity tag-list ":"))))))
diff --git a/contrib/lisp/org-e-html.el b/contrib/lisp/org-e-html.el
index 2c25a6a..5adb305 100644
--- a/contrib/lisp/org-e-html.el
+++ b/contrib/lisp/org-e-html.el
@@ -2071,7 +2071,7 @@ holding contextual information."
(org-element-property :priority headline)))
(text (org-export-data (org-element-property :title headline) info))
(tags (and (plist-get info :with-tags)
- (org-element-property :tags headline)))
+ (org-export-get-tags headline info)))
(headline-label (concat "sec-" (mapconcat 'number-to-string
headline-number "-")))
(format-function (cond
@@ -2100,7 +2100,7 @@ holding contextual information."
(and todo (org-export-data todo info)))))
(todo-type (and todo (org-element-property :todo-type headline)))
(tags (and (plist-get info :with-tags)
- (org-element-property :tags headline)))
+ (org-export-get-tags headline info)))
(priority (and (plist-get info :with-priority)
(org-element-property :priority headline)))
(section-number (and (org-export-numbered-headline-p headline info)
diff --git a/contrib/lisp/org-e-latex.el b/contrib/lisp/org-e-latex.el
index 7acc8bf..67e9197 100644
--- a/contrib/lisp/org-e-latex.el
+++ b/contrib/lisp/org-e-latex.el
@@ -1241,7 +1241,7 @@ holding contextual information."
(and todo (org-export-data todo info)))))
(todo-type (and todo (org-element-property :todo-type headline)))
(tags (and (plist-get info :with-tags)
- (org-element-property :tags headline)))
+ (org-export-get-tags headline info)))
(priority (and (plist-get info :with-priority)
(org-element-property :priority headline)))
;; Create the headline text.
@@ -1360,7 +1360,7 @@ holding contextual information."
(and todo (org-export-data todo info)))))
(todo-type (org-element-property :todo-type inlinetask))
(tags (and (plist-get info :with-tags)
- (org-element-property :tags inlinetask)))
+ (org-export-get-tags inlinetask info)))
(priority (and (plist-get info :with-priority)
(org-element-property :priority inlinetask))))
;; If `org-e-latex-format-inlinetask-function' is provided, call it
diff --git a/contrib/lisp/org-e-odt.el b/contrib/lisp/org-e-odt.el
index 7d719cd..4672bb9 100644
--- a/contrib/lisp/org-e-odt.el
+++ b/contrib/lisp/org-e-odt.el
@@ -3080,7 +3080,7 @@ holding contextual information."
(org-element-property :priority headline)))
(text (org-export-data (org-element-property :title headline) info))
(tags (and (plist-get info :with-tags)
- (org-element-property :tags headline)))
+ (org-export-get-tags headline info)))
(headline-label (concat "sec-" (mapconcat 'number-to-string
headline-number "-")))
(format-function (cond
diff --git a/contrib/lisp/org-export.el b/contrib/lisp/org-export.el
index e9fa2a2..58f1379 100644
--- a/contrib/lisp/org-export.el
+++ b/contrib/lisp/org-export.el
@@ -2823,6 +2823,22 @@ INFO is a plist used as a communication channel."
(pop roman)))
res)))
+(defun org-export-get-tags (element info &optional tags)
+ "Return list of tags associated to ELEMENT.
+
+ELEMENT has either an `headline' or an `inlinetask' type. INFO
+is a plist used as a communication channel.
+
+Select tags (see `org-export-select-tags') and exclude tags (see
+`org-export-exclude-tags') are removed from the list.
+
+When non-nil, optional argument TAGS should be a list of strings.
+Any tag belonging to this list will also be removed."
+ (org-remove-if (lambda (tag) (or (member tag (plist-get info :select-tags))
+ (member tag (plist-get info :exclude-tags))
+ (member tag tags)))
+ (org-element-property :tags element)))
+
(defun org-export-first-sibling-p (headline info)
"Non-nil when HEADLINE is the first sibling in its sub-tree.
INFO is the plist used as a communication channel."
diff --git a/testing/lisp/test-org-export.el b/testing/lisp/test-org-export.el
index e1e77dc..9aedbba 100644
--- a/testing/lisp/test-org-export.el
+++ b/testing/lisp/test-org-export.el
@@ -16,10 +16,6 @@
(unless (featurep 'org-export)
(signal 'missing-test-dependency "org-export"))
-
-
-;;; Tests
-
(defmacro org-test-with-backend (backend &rest body)
"Execute body with an export back-end defined.
@@ -63,6 +59,10 @@ already filled in `info'."
tree (org-export-get-environment))))
,@body)))
+
+
+;;; Tests
+
(ert-deftest test-org-export/parse-option-keyword ()
"Test reading all standard #+OPTIONS: items."
(should
@@ -446,6 +446,42 @@ Paragraph[fn:1]"
+;;; Headlines and Inlinetasks
+
+(ert-deftest test-org-export/get-tags ()
+ "Test `org-export-get-tags' specifications."
+ (let ((org-export-exclude-tags '("noexport"))
+ (org-export-select-tags '("export")))
+ ;; Standard test: tags which are not a select tag, an exclude tag,
+ ;; or specified as optional argument shouldn't be ignored.
+ (should
+ (org-test-with-parsed-data "* Headline :tag:"
+ (org-export-get-tags (org-element-map tree 'headline 'identity info t)
+ info)))
+ ;; Exclude tags are removed.
+ (should-not
+ (org-test-with-parsed-data "* Headline :noexport:"
+ (org-export-get-tags (org-element-map tree 'headline 'identity info t)
+ info)))
+ ;; Select tags are removed.
+ (should-not
+ (org-test-with-parsed-data "* Headline :export:"
+ (org-export-get-tags (org-element-map tree 'headline 'identity info t)
+ info)))
+ (should
+ (equal
+ '("tag")
+ (org-test-with-parsed-data "* Headline :tag:export:"
+ (org-export-get-tags (org-element-map tree 'headline 'identity info t)
+ info))))
+ ;; Tags provided in the optional argument are also ignored.
+ (should-not
+ (org-test-with-parsed-data "* Headline :ignore:"
+ (org-export-get-tags (org-element-map tree 'headline 'identity info t)
+ info '("ignore"))))))
+
+
+
;;; Links
(ert-deftest test-org-export/fuzzy-links ()