emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Valentin Wüstholz" <wuestholz@gmail.com>
To: Nicolas Goaziou <n.goaziou@gmail.com>
Cc: emacs-orgmode <emacs-orgmode@gnu.org>
Subject: Re: [PATCH] org.el: Preserve indentation of manually indented lines in example blocks.
Date: Tue, 9 Aug 2011 21:37:10 +0200	[thread overview]
Message-ID: <CAPVO5ryTyn_HM9ccLSq9PERhNp4-oUJbi=wGUeVz2iGe0nYp4g@mail.gmail.com> (raw)
In-Reply-To: <87vcu6lnzy.fsf@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1438 bytes --]

Hi Nicolas.


On Tue, Aug 9, 2011 at 3:21 PM, Nicolas Goaziou <n.goaziou@gmail.com> wrote:
>> I would love to hear how other people feel about this.
>
> Same here. I don't use such blocks very often after all.
>
> Meanwhile, could you please reformat a bit your patch (no more than 80
> columns, no parents on their own line), add a commit message followed
> by TINYCHANGE (unless you have signed FSF papers already) and use git
> format-patch for the output?


Sure. I have attached the output.


>>> To sum it up, in the first case, you only loose the ability to indent
>>> the whole buffer in one go (which isn't as bad as it sounds, since you
>>> can achieve that differently).
>>
>> How else would you be able to achieve that?
>
> You may still indent regions without examples blocks, you can also
> indent automatically each line you're writing.


True, but that gets quite tedious once you have more than two or three
blocks in your file.


>> I might be wrong, but I believe that at least in LaTeX indentation in
>> verse blocks is not taken into account. This seems reasonable since
>> they are not typeset in a monospaced font.
>
> Actually indentation is partially taken into account. Some \hspace*{1cm}
> are added. On the other hand, HTML enforces indentation with the help of
> &nbsp;.


Your right, it seems that org-mode somehow deals with it, even though
LaTeX doesn't quite support it natively.

Best regards,

Valentin

[-- Attachment #2: 0001-Preserve-indentation-of-explicitly-indented-lines-in.patch.txt --]
[-- Type: text/plain, Size: 1744 bytes --]

From c64f1b607d937c6484dfc18110125b1287175ac4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Valentin=20W=FCstholz?= <wuestholz@gmail.com>
Date: Tue, 9 Aug 2011 21:28:56 +0200
Subject: [PATCH] Preserve indentation of explicitly indented lines in example blocks

* lisp/org.el (org-indent-line-function): Made the way in which example blocks are
  indented more flexible.

Before: Lines in example blocks were indented like the surrounding begin and end
delimiters.
After: By default, lines in example blocks are indented like the surrounding begin and end
delimiters, unless the user explicitly indents them differently.

TINYCHANGE
---
 lisp/org.el |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index ba7f049..d8f1d2a 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -19460,10 +19460,14 @@ If point is in an inline task, mark that task instead."
       (save-excursion
 	(re-search-backward "^[ \t]*#\\+begin_\\([a-z]+\\)" nil t))
       (setq column
-	    (if (equal (downcase (match-string 1)) "src")
-		;; src blocks: let `org-edit-src-exit' handle them
-		(org-get-indentation)
-	      (org-get-indentation (match-string 0)))))
+            (cond ((equal (downcase (match-string 1)) "src")
+                   ;; src blocks: let `org-edit-src-exit' handle them
+                   (org-get-indentation))
+                  ((equal (downcase (match-string 1)) "example")
+                   (max (org-get-indentation)
+			(org-get-indentation (match-string 0))))
+                  (t
+                   (org-get-indentation (match-string 0))))))
      ;; This line has nothing special, look at the previous relevant
      ;; line to compute indentation
      (t
-- 
1.7.4.msysgit.0


  reply	other threads:[~2011-08-09 19:37 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-08 19:48 [PATCH] org.el: Preserve indentation of manually indented lines in example blocks Valentin Wüstholz
2011-08-08 20:40 ` Nicolas Goaziou
2011-08-08 21:04   ` Valentin Wüstholz
2011-08-08 22:33     ` Nicolas Goaziou
2011-08-09  5:42       ` Valentin Wüstholz
2011-08-09  9:18         ` Nicolas Goaziou
2011-08-09 12:10           ` Valentin Wüstholz
2011-08-09 13:21             ` Nicolas Goaziou
2011-08-09 19:37               ` Valentin Wüstholz [this message]
2011-08-10  9:00                 ` Nicolas Goaziou
2011-08-16 17:21                   ` Bastien
2011-08-16 19:18                 ` Bastien
2011-08-16 21:33                   ` Valentin Wüstholz
2011-08-17  9:40                     ` Bastien
2011-08-17 18:32                       ` Valentin Wüstholz
2011-08-18 16:44                         ` Bastien
2011-08-26  6:45                           ` Valentin Wüstholz

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='CAPVO5ryTyn_HM9ccLSq9PERhNp4-oUJbi=wGUeVz2iGe0nYp4g@mail.gmail.com' \
    --to=wuestholz@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=n.goaziou@gmail.com \
    /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).