all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Jarmo Hurri <jarmo.hurri@iki.fi>
To: emacs-orgmode@gnu.org
Subject: Babel code indentation problem
Date: Thu, 03 Mar 2016 10:01:25 +0200	[thread overview]
Message-ID: <87mvqgouqy.fsf@iki.fi> (raw)


Greetings.

I would appreciate help in fixing a Babel indentation problem.  I
recently added support for Processing programming language in Babel. It
is working very nicely except for an indentation problem I ran into.

The Org snippet below shows two basically indentical code blocks, one in
C and the other in Processing. When I edit the code blocks with "C-c '"
and return to the Org file, the C code indents correctly, while the
Processing code doesn't. To be more specific, one line doesn't, and the
line is indicated in the file.

# ------------------------------------------------------------------
* Example with C
  #+BEGIN_SRC c
    #include <stdlib.h>

    int main (int argc, char* argv[])
    {
        int a = 0, b = 0;

        while (a == 0)
        {
            if (a == 0)
            {
                if (b == 0)
                    a++; /* this line indents correctly */
            }
        }
        exit (0);
    }
  #+END_SRC
* Example with Processing
  #+BEGIN_SRC processing
    size (400, 400);

    int a = 0, b = 0;

    while (a == 0)
    {
      if (a == 0)
      {
        if (b == 0)
  	a++; // while this one doesn't
      }
    }
  #+END_SRC
# ------------------------------------------------------------------

Now when I edit the Processing code with "C-c '", go to the problematic
line and press tab, the line is indented correctly:

----------------------------------------------------------------------
size (400, 400);

int a = 0, b = 0;

while (a == 0)
{
  if (a == 0)
  {
    if (b == 0)
      a++; // while this one doesn't
  }
}
----------------------------------------------------------------------

So the problem is not in indentation in Processing mode itself, but the
error appears upon return from editing. This suggests that the issue 
is in the communication between the editing mode and Org mode. As you
can see, I have different indentation settings for C and Processing, so
that might be one thing that makes the difference appear.

The incorrect indentation carries over to, for example, exported files.

Any ideas on how I would start fixing this?

Jarmo

             reply	other threads:[~2016-03-03  8:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-03  8:01 Jarmo Hurri [this message]
2016-03-03 10:14 ` Babel code indentation problem Eric S Fraga
2016-03-03 10:50   ` Jarmo Hurri

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87mvqgouqy.fsf@iki.fi \
    --to=jarmo.hurri@iki.fi \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.