From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael Bach Subject: Re: Import files to babel blocks Date: Thu, 25 Jul 2013 01:00:57 +0200 Message-ID: <51F05CA9.1060301@gmail.com> References: <87txjoi4pu.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:53832) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V283M-0005oG-0I for emacs-orgmode@gnu.org; Wed, 24 Jul 2013 19:01:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V283J-0005Ev-Uy for emacs-orgmode@gnu.org; Wed, 24 Jul 2013 19:01:03 -0400 Received: from mail-ee0-x234.google.com ([2a00:1450:4013:c00::234]:52187) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V283J-0005Ek-ON for emacs-orgmode@gnu.org; Wed, 24 Jul 2013 19:01:01 -0400 Received: by mail-ee0-f52.google.com with SMTP id c50so546530eek.25 for ; Wed, 24 Jul 2013 16:01:00 -0700 (PDT) In-Reply-To: <87txjoi4pu.fsf@gmail.com> 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: Myles English Cc: emacs-orgmode@gnu.org 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