From mboxrd@z Thu Jan 1 00:00:00 1970 From: simon@psilas.com Subject: Re: Separate Org file from Subtree Date: Mon, 16 Feb 2015 14:40:59 +0000 Message-ID: <1424097659.1889829.228103853.29471F3B@webmail.messagingengine.com> References: <1424083270.1791871.228021221.7DB94916@webmail.messagingengine.com> Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:35619) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YNMrA-0001wi-1I for emacs-orgmode@gnu.org; Mon, 16 Feb 2015 09:41:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YNMr6-0002ob-Ko for emacs-orgmode@gnu.org; Mon, 16 Feb 2015 09:41:03 -0500 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:36298) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YNMr6-0002oN-61 for emacs-orgmode@gnu.org; Mon, 16 Feb 2015 09:41:00 -0500 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 30FA820BCD for ; Mon, 16 Feb 2015 09:40:58 -0500 (EST) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: John Kitchin Cc: emacs-orgmode@gnu.org Thanks very much for this John. As you say, the normal export "C-c C-e C-s O o" does not work as expected. Your function exported the properties properly, but seemed to work on the visible text only and wouldn't export the content of headings (unless I unfold them all prior to import). If the article was like this: * DONE Article One :PROPERTIES: :EXPORT_TITLE: An Interesting Article :EXPORT_AUTHOR: Simon Jones :EXPORT_FILE_NAME: an-interesting-article :EXPORT_DATE: 2015-02-16 :END: Article content .... ** Section title Section content it would export as intended but without the section content. Thanks again for your time. Simon ------- On Mon, 16 Feb 2015, at 12:54 PM, John Kitchin wrote: > Change :EXPORT_FILENAME: an-interesting-article to :EXPORT_FILE_NAME: > an-interesting-article > > Then, > > C-c C-e C-s O o > > should export to that file. I notice in the org export that the > properties are not getting exported, and even the headline is not > exported as the title though. > > Here is a function that seems to do what you want. > > #+BEGIN_SRC emacs-lisp > (defun export-subtree () > (interactive) > (let ((fname (concat (org-entry-get (point) "EXPORT_FILE_NAME") > ".org")) > (author (org-entry-get (point) "EXPORT_AUTHOR")) > (title (org-entry-get (point) "EXPORT_TITLE")) > (date (org-entry-get (point) "EXPORT_DATE")) > (content (progn (set-buffer (org-org-export-as-org nil t t)) > (buffer-string)))) > ;; warning you can delete something unintentionally > (when (file-exists-p fname) (delete-file fname)) > (find-file fname) > (insert "#+TITLE: " title "\n") > (insert "#+AUTHOR: " author "\n") > (insert "#+DATE: " date "\n") > (insert "\n" content) > ;; remove properties drawer. Kind of hacky. > (goto-char (point-min)) > (re-search-forward ":PROPERTIES:") > (setf (buffer-substring > (org-element-property :begin (org-element-context)) > (org-element-property :end (org-element-context))) > "") > (save-buffer))) > > (export-subtree) > #+END_SRC > > simon@psilas.com writes: > > > Hi there, > > > > I think I must be missing something. > > > > I have a collection of articles in one org file (under separate > > headings). I can export these as a subtree using Org's normal export > > function as html etc., but I want to export the selected subtree as an > > individual org file using the properties under each heading.) > > > > In other words I want to export this subtree ... > > * DONE Article One > > :PROPERTIES: > > :EXPORT_TITLE: An Interesting Article > > :EXPORT_AUTHOR: Simon Jones > > :EXPORT_FILENAME: an-interesting-article > > :EXPORT_DATE: 2015-02-16 > > :END: > > > > Article content .... > > > > into an Org file entitled 'an-interesting-article.org' that looks like > > this ... > > > > #+TITLE: An Interesting Article > > #+AUTHOR: Simon Jones > > #+DATE: 2015-02-16 > > > > Article content... > > > > Can anyone help me with this? I'm very sorry if I'm missing something > > obvious. > > > > Simon. > > -- > Professor John Kitchin > Doherty Hall A207F > Department of Chemical Engineering > Carnegie Mellon University > Pittsburgh, PA 15213 > 412-268-7803 > @johnkitchin > http://kitchingroup.cheme.cmu.edu