From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ilya Shlyakhter Subject: Re: inline source code blocks Date: Thu, 06 Mar 2014 18:35:29 -0500 Message-ID: References: <874n3bug4r.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:60685) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WLhq0-0003bk-7k for emacs-orgmode@gnu.org; Thu, 06 Mar 2014 18:37:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WLhpM-0004Tj-9Q for emacs-orgmode@gnu.org; Thu, 06 Mar 2014 18:36:28 -0500 Received: from plane.gmane.org ([80.91.229.3]:55297) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WLhpL-0004TN-MY for emacs-orgmode@gnu.org; Thu, 06 Mar 2014 18:35:47 -0500 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1WLhpE-000303-I2 for emacs-orgmode@gnu.org; Fri, 07 Mar 2014 00:35:40 +0100 Received: from wrls-140-247-0-35.wrls.harvard.edu ([140.247.0.35]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 07 Mar 2014 00:35:40 +0100 Received: from ilya_shl by wrls-140-247-0-35.wrls.harvard.edu with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 07 Mar 2014 00:35:40 +0100 In-Reply-To: <874n3bug4r.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: emacs-orgmode@gnu.org On 3/6/14 5:04 PM, Eric Schulte wrote: > I think code blocks work well for non-inline code. For a series of one-liners interspersed with comments, code block boundaries triple the number of lines. E.g. the example in the manual at http://orgmode.org/org.html#noweb_002dref +BEGIN_SRC sh :tangle yes :noweb yes :shebang #!/bin/sh <> #+END_SRC * the mount point of the fullest disk :PROPERTIES: :noweb-ref: fullest-disk :END: ** query all mounted disks #+BEGIN_SRC sh df \ #+END_SRC ** strip the header row #+BEGIN_SRC sh |sed '1d' \ #+END_SRC ** sort by the percent full #+BEGIN_SRC sh |awk '{print $5 " " $6}'|sort -n |tail -1 \ #+END_SRC ** extract the mount point #+BEGIN_SRC sh |awk '{print $2}' #+END_SRC could be shortened to #+PROPERTY: ob-default-lang sh #+HEADER: :tangle yes :noweb yes :shebang #!/bin/sh : <> * the mount point of the fullest disk :PROPERTIES: :noweb-ref: fullest-disk :END: ** query all mounted disks : df \ ** strip the header row : |sed '1d' \ ** sort by the percent full : |awk '{print $5 " " $6}'|sort -n |tail -1 \ ** extract the mount point : |awk '{print $2}' i.e. where the (inherited) property ob-default-lang exists, literal examples become code blocks in that language. Or in a list of C++ declarations: #+PROPERTY: ob-default-lang c++ ... * class MyClass Does X, Y and Z. : class MyClass: public MyParent { ** Private fields *** Field a: stores thing one : int a; *** Field b: stores thing two : char *b; ** Public methods : public: *** Method getA: Returns the value of a. : int getA() const { return a; } ** end class MyClass :} I'm finding that Org would work well as a literate programming system for C++, if the code block starts and ends didn't get in the way so much during frequent switching between code and prose. > I use the following to make code block syntax less intrusive Thanks, that was helpful, didn't know about compose-region. Still, it does not reduce the number of lines used, so a short list of declarations interspersed with comments quickly ends up taking a lot of vertical space. When coding it helps to be able to see many things at once, and having many extra lines (even mostly-blank ones) makes that difficult. ilya