From mboxrd@z Thu Jan 1 00:00:00 1970 From: Myles English Subject: Re: Import files to babel blocks Date: Sun, 21 Jul 2013 11:31:57 +0100 Message-ID: <87txjoi4pu.fsf@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:43007) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V0qss-0005ib-Mm for emacs-orgmode@gnu.org; Sun, 21 Jul 2013 06:28:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V0qsr-0002zd-Is for emacs-orgmode@gnu.org; Sun, 21 Jul 2013 06:28:58 -0400 Received: from mail-wi0-x235.google.com ([2a00:1450:400c:c05::235]:51632) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V0qsr-0002yu-CV for emacs-orgmode@gnu.org; Sun, 21 Jul 2013 06:28:57 -0400 Received: by mail-wi0-f181.google.com with SMTP id hq4so945051wib.2 for ; Sun, 21 Jul 2013 03:28:56 -0700 (PDT) In-reply-to: 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: Michael Bach Cc: emacs-orgmode@gnu.org 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