emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Francesco Pizzolante" <fpz-djc/iPCCuDYQheJpep6IedvLeJWuRmrY@public.gmane.org>
To: mailing-list-org-mode <emacs-orgmode-mXXj517/zsQ@public.gmane.org>
Subject: Indentation of code blocks within lists
Date: Mon, 13 May 2013 14:11:47 +0200	[thread overview]
Message-ID: <87ehdb13lo.fsf@somewhere.org> (raw)

Hi All,

I'd like to let you know about issues I'm having while trying to put source
code blocks within lists.

Here's my example and how I indent it:

--8<---------------cut here---------------start------------->8---
* First situation

- My first bullet

  We need to do this:

  #+begin_src emacs-lisp
  (message "this is a string")
  (defun x()
    "Doc..."
    (interactive)
    (message "hello"))
  #+end_src

- My second bullet

  #+begin_src emacs-lisp
  "test"
  #+end_src

  #+results:
  : test

  - Sub-point of second bullet

    We need to do this as well:

    #+begin_src emacs-lisp
    (sort)
    #+end_src
--8<---------------cut here---------------end--------------->8---

This way if indenting code blocks has the following advantages:

- it looks nice;

- thanks to the indentation, you directly know at which list level the code
  block belongs to;

- you can easily use Emacs commands (like `C-x TAB') on regions or Org
  promote/demote commands on items or subtrees to edit and reorganize your
  text: "relative" indentation is preserved in all cases.

But, I have 2 issues with it:

- when using `C-c '' (`org-edit-special'), I see spaces before my code, while
  I would expect to see my code starting at column 0 in the edit buffer (the
  "reference" column for the "margin" being, here, the column with the '#'
  from '#+begin_src';

- when exporting, the spaces from column 0 to the start of my code are also
  exported, while I would again expect these spaces to be ignored for the
  export.

The only way I found to fix these issues is to edit my text like this (and
make any code to start in column 0):

--8<---------------cut here---------------start------------->8---
- My first bullet

  We need to do this:

  #+begin_src emacs-lisp
(message "this is a string")
(defun x()
  "Doc..."
  (interactive)
  (message "hello"))
  #+end_src

- My second bullet

  #+begin_src emacs-lisp
"test"
  #+end_src

  #+results:
  : test

  - Sub-point of second bullet

    We need to do this as well:

    #+begin_src emacs-lisp
(sort)
    #+end_src
--8<---------------cut here---------------end--------------->8---

But:

- as you can see, the text does not look anymore as nice as in the previous
  example;

- I'm no longer able to edit and reorganize the text using Emacs `C-x TAB'
  command. That command becomes "forbidden" as it can't correctly respect the
  indentation requirements:

  + starting at column 0 for code;

  + relative for list items (depending on their depth);

- even Org promote/demote commands are buggy in this case: as a simple
  example, when I try to promote (with M-Shift-Left) the last point "Sub-point
  of second bullet" I get an error ("indent-line-to: Wrong type argument:
  wholenump, -2" ) and the following half-baked result:

--8<---------------cut here---------------start------------->8---
  - Sub-point of second bullet

    We need to do this:

    #+begin_src emacs-lisp
(sort)
  #+end_src
--8<---------------cut here---------------end--------------->8---

  The "#+end_src" line got misaligned.

So, my question is the following: is there a way to edit my text as shown in
the first example and edit/export it ignoring the "margin" spaces?

Any help is welcome.

Thanks a lot,
 Francesco

             reply	other threads:[~2013-05-13 12:11 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-13 12:11 Francesco Pizzolante [this message]
     [not found] ` <87ehdb13lo.fsf-oHC15RC7JGTNLxjTenLetw@public.gmane.org>
2013-05-21  8:25   ` Indentation of code blocks within lists Francesco Pizzolante
2013-05-23 22:20     ` Sebastien Vauban
2013-05-24 12:31       ` Nicolas Goaziou
     [not found]         ` <87sj1c7e60.fsf-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-05-24 14:33           ` Francesco Pizzolante
2013-05-24 21:26         ` Sebastien Vauban
2013-05-25 12:39           ` Nicolas Goaziou
     [not found]             ` <87zjvj5j3n.fsf-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-05-27  8:23               ` Francesco Pizzolante
2013-05-27 14:15             ` Sebastien Vauban
2013-05-27 14:46               ` Sebastien Vauban

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

  List information: https://www.orgmode.org/

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

  git send-email \
    --in-reply-to=87ehdb13lo.fsf@somewhere.org \
    --to=fpz-djc/ipccudyqhejpep6iedvlejwurmry@public.gmane.org \
    --cc=emacs-orgmode-mXXj517/zsQ@public.gmane.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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).