emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Michael Bach <phaebz@gmail.com>
To: Myles English <mylesenglish@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: Import files to babel blocks
Date: Thu, 25 Jul 2013 01:00:57 +0200	[thread overview]
Message-ID: <51F05CA9.1060301@gmail.com> (raw)
In-Reply-To: <87txjoi4pu.fsf@gmail.com>

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

      reply	other threads:[~2013-07-24 23:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-21  8:41 Import files to babel blocks Michael Bach
2013-07-21 10:31 ` Myles English
2013-07-24 23:00   ` Michael Bach [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51F05CA9.1060301@gmail.com \
    --to=phaebz@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=mylesenglish@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).