From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sankalp Subject: Re: Including source code *from* a file in #+BEGIN_SRC blocks Date: Sun, 11 Dec 2011 22:38:21 +0530 Message-ID: References: <87aa6z82ws.fsf@gmx.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=f46d043be01afa718b04b3d411ff Return-path: Received: from eggs.gnu.org ([140.186.70.92]:54463) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RZmtI-0006d2-PC for emacs-orgmode@gnu.org; Sun, 11 Dec 2011 12:08:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RZmtH-0005Uf-JN for emacs-orgmode@gnu.org; Sun, 11 Dec 2011 12:08:44 -0500 Received: from mail-vx0-f169.google.com ([209.85.220.169]:54232) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RZmtH-0005UZ-Cv for emacs-orgmode@gnu.org; Sun, 11 Dec 2011 12:08:43 -0500 Received: by vcbfk26 with SMTP id fk26so3879820vcb.0 for ; Sun, 11 Dec 2011 09:08:42 -0800 (PST) In-Reply-To: <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: emacs-orgmode --f46d043be01afa718b04b3d411ff Content-Type: text/plain; charset=ISO-8859-1 On 11 December 2011 21:30, 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. > > Best -- Eric > > -- > Eric Schulte > http://cs.unm.edu/~eschulte/ > Thanks a lot Eric, though I got it working with what Puneeth suggested earlier :) -- Sankalp --f46d043be01afa718b04b3d411ff Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
On 11 December 2011 21:30, Eric Schulte <eric.schulte@gmx.com<= /a>> wrote:
Sankalp <san= kalpkhare@gmail.com> writes:

> Hi,
> I've been using org mode's #+BEGIN_SRC ... <code> #+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 LaT= eX *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. =A0For example if your external file is named foo.c and holds C
code the following

#+begin_src sh :exports results :results raw output
=A0echo "#+BEGIN_SRC C"
=A0cat foo.c
=A0echo "#+END_SRC"
#+end_src

will insert its contents into the buffer during every export.

Best -- Eric

--
Eric Schulte
http://cs.unm.ed= u/~eschulte/

Thanks a lot Eric, though I got it working wit= h what Puneeth suggested earlier :)

--
Sankalp
--f46d043be01afa718b04b3d411ff--