emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Possible to use src block to generate org headlines for export?


From: Matt Lundin
Subject: Re: [O] Possible to use src block to generate org headlines for export?
Date: Tue, 22 Jul 2014 21:35:55 -0500
User-agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/24.3 (gnu/linux)

Nick Dokos <address@hidden> writes:
>>
>> In short, is there a more graceful and export-friendly way to use babel
>> to generate org headlines for export? Or is there an easy way to get the
>> export backend to delete the opening part of the drawer (i.e.,
>> :RESULTS:)?
>>
>> Any advice would be greatly appreciated. 
>>
>
> No solace for your pain alas.  See
> http://thread.gmane.org/gmane.emacs.orgmode/88557
>
> My suggestion (as it was for Ronald, except that he had already rejected
> it :-) ) would be to use raw: you lose the idempotency of results
> production, but I don't know of any other problems.

Thanks for the link. My ignorance of it shows how far behind I am on
orgmode ML reading!

I agree with Nicolas's argument that only headlines can contain
headlines.

That said, having the ability to generate org copy for export also seems
useful.

I wonder whether org-babel might take advantage of COMMENT headlines for
org output: E.g.

* COMMENT Here beginneth the results for code block named "do-some-magic"
* COMMENT Here endeth the results for code block named "do-some-magic"

Obviously, this could wreak havoc on ones outline structure, so some
extra magic would be needed to set the correct headline level.

However, since the headlines I'm generating are always at the end of the
file, I've hacked my way to a solution with the following:

--8<---------------cut here---------------start------------->8---
#+BEGIN_SRC emacs-lisp :exports none :results none
  (save-excursion
    (goto-char (point-min))
    (while (re-search-forward "#\\+RESULTS: generate-blog-summary" nil t)
      (beginning-of-line)
      (delete-region (point) (point-max))))
#+END_SRC

#+NAME: generate-blog-summary
#+BEGIN_SRC perl :exports results :results output org raw
  print "* Headline One\n";
  print "* Headline Two\n";
  print "* Headline Three\n";
#+END_SRC
--8<---------------cut here---------------end--------------->8---

Thus, each time I export, the emacs-lisp snippet nicely deletes the old
results, making space for the new ones. 

Let's hope the real blog (when I get around to publishing it) is more
interesting than the example above. ;)

Best,
Matt



reply via email to

[Prev in Thread] Current Thread [Next in Thread]