emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] Import files to babel blocks


From: Myles English
Subject: Re: [O] Import files to babel blocks
Date: Sun, 21 Jul 2013 11:31:57 +0100
User-agent: mu4e 0.9.9.5-dev6; emacs 24.3.1

Hi Michael,

Michael Bach writes:

> Dear org-mode Users and Developers,
>
> I am trying to write a simple function for importing files to org-mode
> babel code blocks.
>
> My naive approach was
>
> --8<---------------cut here---------------start------------->8---
> (defun import-to-org-from-files (path pattern progmode)
>   (mapcar #'(lambda (filepath)
>               (progn
>                 (insert (format
>                          "\n#+name: %s\n" (file-name-nondirectory
>                                            (file-name-sans-extension
>                                             filepath))))
>                 (insert (format "#+begin_src: %s :eval no\n" progmode))
>                 (insert-file-contents filepath)

>From the documentation (C-h f insert-file-contents), it says that it
"returns list of absolute file name and number of characters" but
doesn't move the marker forwards, unlike insert does.  So, I guess you
would have to then move the marker forwards by the number of characters.

>                 (insert "\n#+end_src\n"))
>               )
>           (directory-files path t pattern)))
> --8<---------------cut here---------------end--------------->8---

Myles



reply via email to

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