Hi Bastien and all,

On Sun, 30 Oct 2011 09:48:06 +0100
Bastien <b...@altern.org> wrote:

> Suvayu Ali <fatkasuvayu+li...@gmail.com> writes:
>
> > That said, the problem I am facing is org-export-with-tags
> > evaluates to not-in-toc irrespective of what is set by the tags:
> > option (see for example the test file earlier in the thread). So
> > effectively the test is not checking what it is supposed to check.
> > So I was wondering whether I missed something I should be doing.
>
> The problem is that `org-export-with-tags' is a global option,
> storing the default value for any buffer (and _a fortiori_ any
> subtree) -- while you want to check local options, which may
> be different at export time.
>
> Local options are stored in a `org-export-opt-plist'.  You get
> the value of the "tags:" option by checking the property list
> like this:
>
>   (plist-get org-export-opt-plist :tags))
>
> Hence the patch below, which you can try to make sure it does
> what you want.
>

That seems to work only when the EXPORT_OPTIONS property is set for the
subtree. Without the property, it doesn't pick up the tags:nil option
from the file header. Actually, the property list doesn't even have
the tags: property in it.

However I did find a solution along those lines and the final patch is
attached. :)

Cheers,

-- 
Suvayu

Open source is the future. It sets us free.
From dac022f103f8498de96fa5d0e40e0b840ae9c7fb Mon Sep 17 00:00:00 2001
From: Suvayu Ali <fatkasuvayu+li...@gmail.com>
Date: Wed, 2 Nov 2011 00:26:07 +0100
Subject: [PATCH] Respect export options for subtree export title

* org-exp.el (org-solidify-link-text): Respect org-export-with-tags
  when forming the export title during subtree export.

TINY CHANGE
---
 lisp/org-exp.el |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/lisp/org-exp.el b/lisp/org-exp.el
index fa54242..e8ad0b9 100644
--- a/lisp/org-exp.el
+++ b/lisp/org-exp.el
@@ -2160,15 +2160,21 @@ (defun org-export-grab-title-from-buffer ()
 (defun org-export-get-title-from-subtree ()
   "Return subtree title and exclude it from export."
   (let ((rbeg (region-beginning)) (rend (region-end))
-	(inhibit-read-only t) title)
+	(inhibit-read-only t)
+	(tags (plist-get (org-infile-export-plist) :tags))
+	title)
     (save-excursion
       (goto-char rbeg)
       (when (and (org-at-heading-p)
 		 (>= (org-end-of-subtree t t) rend))
+	(when (plist-member org-export-opt-plist :tags)
+	  (setq tags (or (plist-get org-export-opt-plist :tags) tags)))
 	;; This is a subtree, we take the title from the first heading
 	(goto-char rbeg)
-	(looking-at org-todo-line-regexp)
-	(setq title (match-string 3))
+	(looking-at org-todo-line-tags-regexp)
+	(setq title (if (eq tags t)
+			(format "%s\t%s" (match-string 3) (match-string 4))
+		      (match-string 3)))
 	(org-unmodified
 	 (add-text-properties (point) (1+ (point-at-eol))
 			      (list :org-license-to-kill t)))
-- 
1.7.7

Reply via email to