[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] Import files to babel blocks
From: |
Michael Bach |
Subject: |
Re: [O] Import files to babel blocks |
Date: |
Thu, 25 Jul 2013 01:00:57 +0200 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:17.0) Gecko/20130620 Thunderbird/17.0.7 |
Hi Myles,
On 7/21/13 12:31 PM, Myles English wrote:
>
> 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.
>
Erhm, another case of readthedocs... Thanks for the shove! For
reference, I got it to work using a simple let like so:
--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))
(let ((res (insert-file-contents filepath)))
(forward-char (second res)))
(insert "\n#+end_src\n"))
)
(directory-files path t pattern)))
--8<---------------cut here---------------end--------------->8---
much obliged,
Michael