From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: Including source code *from* a file in #+BEGIN_SRC blocks Date: Sun, 11 Dec 2011 09:00:24 -0700 Message-ID: <87aa6z82ws.fsf@gmx.com> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([140.186.70.92]:55193) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RZmfh-0008La-UJ for emacs-orgmode@gnu.org; Sun, 11 Dec 2011 11:54:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RZmfg-0002wO-Aq for emacs-orgmode@gnu.org; Sun, 11 Dec 2011 11:54:41 -0500 Received: from mailout-us.gmx.com ([74.208.5.67]:54382 helo=mailout-us.mail.com) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1RZmff-0002wA-Sv for emacs-orgmode@gnu.org; Sun, 11 Dec 2011 11:54:40 -0500 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: Sankalp Cc: emacs-orgmode 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/