From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: Including source code *from* a file in #+BEGIN_SRC blocks Date: Sun, 11 Dec 2011 14:22:10 -0500 Message-ID: <22202.1323631330@alphaville.dokosmarshall.org> References: <87aa6z82ws.fsf@gmx.com> Reply-To: nicholas.dokos@hp.com Return-path: Received: from eggs.gnu.org ([140.186.70.92]:53799) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RZoyU-0002pE-BZ for emacs-orgmode@gnu.org; Sun, 11 Dec 2011 14:22:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RZoyT-0000lx-7k for emacs-orgmode@gnu.org; Sun, 11 Dec 2011 14:22:14 -0500 Received: from g5t0006.atlanta.hp.com ([15.192.0.43]:40005) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RZoyT-0000lt-4E for emacs-orgmode@gnu.org; Sun, 11 Dec 2011 14:22:13 -0500 In-Reply-To: Message from Eric Schulte of "Sun, 11 Dec 2011 09:00:24 MST." <87aa6z82ws.fsf@gmx.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: Eric Schulte Cc: Sankalp , nicholas.dokos@hp.com, emacs-orgmode Eric Schulte wrote: > Sankalp writes: > > > Hi, > > I've been using org mode's #+BEGIN_SRC ... #+END_SRC feature to > > display source code. > > > > I was wondering if there's a way to include code from an external file. > > Like the *\lstinputlisting* feature in the LaTeX *listings* package. > > > > You could write a code block which when executed wraps the file's > contents in a code block which is then inserted into the Org-mode > buffer. For example if your external file is named foo.c and holds C > code the following > > #+begin_src sh :exports results :results raw output > echo "#+BEGIN_SRC C" > cat foo.c > echo "#+END_SRC" > #+end_src > > will insert its contents into the buffer during every export. > That might be necessary in more complex situations, but in the OP's case (at least, to the extent that I understand it), Puneeth's suggestion of #+begin_src c :exports code #+include: foo.c #+end_src seems to work fine. Nick