emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* struggling with simple indentation
@ 2010-10-25 12:35 Rainer Stengele
  2010-10-25 17:06 ` Nicolas Goaziou
  0 siblings, 1 reply; 11+ messages in thread
From: Rainer Stengele @ 2010-10-25 12:35 UTC (permalink / raw)
  To: emacs-orgmode

Dear all,

I am struggling with a simple indentation problem.

Having this: (1)
====================================================================

***** test
      - indented
line
^

point at "^" and pressing TAB results in:


***** test
      - indented
      line
      ^
====================================================================

Having this: (2)

***** test
      - indented
      - indented
line
^

point at "^" and pressing TAB results in:


***** test
      - indented
      - indented
line
^

====================================================================

I want to consistently indent lines like in case (1).
Why does org not indent in case (2)
How can I change this behavior? Is it a config issue?

I could not find a variable where I could adapt the indentation behavior.

Best
Rainer

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: struggling with simple indentation
  2010-10-25 12:35 struggling with simple indentation Rainer Stengele
@ 2010-10-25 17:06 ` Nicolas Goaziou
  2010-10-26  8:45   ` Rainer Stengele
  0 siblings, 1 reply; 11+ messages in thread
From: Nicolas Goaziou @ 2010-10-25 17:06 UTC (permalink / raw)
  To: Rainer Stengele; +Cc: emacs-orgmode

Hello,

>>>>> Rainer Stengele writes:

> Dear all,

> I am struggling with a simple indentation problem.

> Having this: (1)
> ====================================================================

> ***** test
>       - indented
> line
> ^

> point at "^" and pressing TAB results in:


> ***** test
>       - indented
>       line
> ====================================================================

> Having this: (2)

> ***** test
>       - indented
>       - indented
> line
> ^

> point at "^" and pressing TAB results in:


> ***** test
>       - indented
>       - indented
> line
> ====================================================================

I cannot reproduce this. I always get case (1). Are you using
development version ?

Regards,

-- Nicolas

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: struggling with simple indentation
  2010-10-25 17:06 ` Nicolas Goaziou
@ 2010-10-26  8:45   ` Rainer Stengele
  2010-10-26  9:05     ` Nicolas Goaziou
  2010-10-26  9:06     ` Nicolas Goaziou
  0 siblings, 2 replies; 11+ messages in thread
From: Rainer Stengele @ 2010-10-26  8:45 UTC (permalink / raw)
  Cc: emacs-orgmode

Am 25.10.2010 19:06, schrieb Nicolas Goaziou:
> Hello,
> 
>>>>>> Rainer Stengele writes:
> 
>> Dear all,
> 
>> I am struggling with a simple indentation problem.
> 
>> Having this: (1)
>> ====================================================================
> 
>> ***** test
>>       - indented
>> line
>> ^
> 
>> point at "^" and pressing TAB results in:
> 
> 
>> ***** test
>>       - indented
>>       line
>> ====================================================================
> 
>> Having this: (2)
> 
>> ***** test
>>       - indented
>>       - indented
>> line
>> ^
> 
>> point at "^" and pressing TAB results in:
> 
> 
>> ***** test
>>       - indented
>>       - indented
>> line
>> ====================================================================
> 
> I cannot reproduce this. I always get case (1). Are you using
> development version ?
> 
> Regards,
> 
> -- Nicolas
> 
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
> 

Nicolas, thanks for checking. Yes I use the development version.
After I git - pulled the indentation works now. Must have been an intermediate problem.

One thing that is annoying me still:

Having

** headline
   - indent
text
^

and pressing "TAB" I end up with

** headline
   - indent
   text
   ^

but would like to have

** headline
   - indent
     text
     ^

Is this configurable?


Regards,

-- Rainer

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: struggling with simple indentation
  2010-10-26  8:45   ` Rainer Stengele
@ 2010-10-26  9:05     ` Nicolas Goaziou
  2010-10-26  9:06     ` Nicolas Goaziou
  1 sibling, 0 replies; 11+ messages in thread
From: Nicolas Goaziou @ 2010-10-26  9:05 UTC (permalink / raw)
  To: Rainer Stengele; +Cc: emacs-orgmode

Hello,

>>>>> Rainer Stengele writes:

> One thing that is annoying me still:

> Having

> ** headline
>    - indent
> text
> ^

> and pressing "TAB" I end up with

> ** headline
>    - indent
>    text
>    ^

> but would like to have

> ** headline
>    - indent
>      text
>      ^

> Is this configurable?

Yes. The less intrusive way of obtaining this is to use C-j instead of
RET after the "indent" line.

If you do not want lists to rely on indentation ever, you can set
`org-list-ending-method' to `regexp'. In this case, only blank lines
can end a list (see variable doc-string for more information), so
"text" will get back into the item after pressing TAB.

Regards,

-- Nicolas

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: struggling with simple indentation
  2010-10-26  8:45   ` Rainer Stengele
  2010-10-26  9:05     ` Nicolas Goaziou
@ 2010-10-26  9:06     ` Nicolas Goaziou
  2010-10-26 10:09       ` Rainer Stengele
  1 sibling, 1 reply; 11+ messages in thread
From: Nicolas Goaziou @ 2010-10-26  9:06 UTC (permalink / raw)
  To: Rainer Stengele; +Cc: emacs-orgmode

Hello,

>>>>> Rainer Stengele writes:

> One thing that is annoying me still:

> Having

> ** headline
>    - indent
> text
> ^

> and pressing "TAB" I end up with

> ** headline
>    - indent
>    text
>    ^

> but would like to have

> ** headline
>    - indent
>      text
>      ^

> Is this configurable?

Yes. The less intrusive way of obtaining this is to use C-j instead of
RET after the "indent" line.

If you do not want lists to rely on indentation ever, you can set
`org-list-ending-method' to `regexp'. In this case, only blank lines
can end a list (see variable doc-string for more information), so
"text" will get back into the item after pressing TAB.

Regards,

-- Nicolas

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: struggling with simple indentation
  2010-10-26  9:06     ` Nicolas Goaziou
@ 2010-10-26 10:09       ` Rainer Stengele
  2010-10-26 10:58         ` Nicolas Goaziou
  0 siblings, 1 reply; 11+ messages in thread
From: Rainer Stengele @ 2010-10-26 10:09 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode

Am 26.10.2010 11:06, schrieb Nicolas Goaziou:
> Hello,
> 
>>>>>> Rainer Stengele writes:
> 
>> One thing that is annoying me still:
> 
>> Having
> 
>> ** headline
>>    - indent
>> text
>> ^
> 
>> and pressing "TAB" I end up with
> 
>> ** headline
>>    - indent
>>    text
>>    ^
> 
>> but would like to have
> 
>> ** headline
>>    - indent
>>      text
>>      ^
> 
>> Is this configurable?
> 
> Yes. The less intrusive way of obtaining this is to use C-j instead of
> RET after the "indent" line.
> 
> If you do not want lists to rely on indentation ever, you can set
> `org-list-ending-method' to `regexp'. In this case, only blank lines
> can end a list (see variable doc-string for more information), so
> "text" will get back into the item after pressing TAB.
> 
> Regards,
> 
> -- Nicolas
> 

Thanks! C-j is best. I still struggle with indentation:

Sometime I do save some an email body text under an org item.
Pasting the text under "item" leads to

* heading
  - item
E-Mail body text line1
E-Mail body text line2
...

Now I cannot use C-j of course. How do I easily get

* heading
  - item
    E-Mail body text line1
    E-Mail body text line2
    ...

TAB as explained does not what I want.
Do you have an idea? "indent-region" does also the "wrong" thing.

Regards,

-- Rainer

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: struggling with simple indentation
  2010-10-26 10:09       ` Rainer Stengele
@ 2010-10-26 10:58         ` Nicolas Goaziou
  2010-10-26 12:25           ` Carsten Dominik
  2010-10-26 15:10           ` Re: struggling with simple indentation (possible bug) Anthony Lander
  0 siblings, 2 replies; 11+ messages in thread
From: Nicolas Goaziou @ 2010-10-26 10:58 UTC (permalink / raw)
  To: Rainer Stengele; +Cc: emacs-orgmode

Hello,
>>>>> Rainer Stengele writes:

> Sometime I do save some an email body text under an org item.
> Pasting the text under "item" leads to

> * heading
>   - item 
> E-Mail body text line1
> E-Mail body text line2
> ...

> Now I cannot use C-j of course. How do I easily get

> * heading
>   - item
>     E-Mail body text line1
>     E-Mail body text line2
>     ...

There is no way for Org to guess what you have in mind here (and this
is why I don't like that much the "indent" method in
`org-list-ending-method').

In your situation, I would use C-x r o with an adequate rectangle
selection. After all, we are _also_ in Emacs.

Regards,

-- Nicolas

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Re: struggling with simple indentation
  2010-10-26 10:58         ` Nicolas Goaziou
@ 2010-10-26 12:25           ` Carsten Dominik
  2010-10-26 13:12             ` Nicolas Goaziou
  2010-10-26 15:10           ` Re: struggling with simple indentation (possible bug) Anthony Lander
  1 sibling, 1 reply; 11+ messages in thread
From: Carsten Dominik @ 2010-10-26 12:25 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode, Rainer Stengele


On Oct 26, 2010, at 12:58 PM, Nicolas Goaziou wrote:

> Hello,
>>>>>> Rainer Stengele writes:
>
>> Sometime I do save some an email body text under an org item.
>> Pasting the text under "item" leads to
>
>> * heading
>>  - item
>> E-Mail body text line1
>> E-Mail body text line2
>> ...
>
>> Now I cannot use C-j of course. How do I easily get
>
>> * heading
>>  - item
>>    E-Mail body text line1
>>    E-Mail body text line2
>>    ...
>
> There is no way for Org to guess what you have in mind here (and this
> is why I don't like that much the "indent" method in
> `org-list-ending-method').

I think it would be OK to modify the indentation code to
do the most useful thing in this case, which is indenting
to under the list.  Is is OK to put the burden for
terminating list by indentation on the user.  The reason why
I wanted this was mostly so that old files still publish
the same way.  I myself has switched to leave two empty
lines to terminate my lists and enjoy the consistent
indentation that results from this.

- Carsten

>
> In your situation, I would use C-x r o with an adequate rectangle
> selection. After all, we are _also_ in Emacs.
>
> Regards,
>
> -- Nicolas
>
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

- Carsten

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Re: struggling with simple indentation
  2010-10-26 12:25           ` Carsten Dominik
@ 2010-10-26 13:12             ` Nicolas Goaziou
  0 siblings, 0 replies; 11+ messages in thread
From: Nicolas Goaziou @ 2010-10-26 13:12 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: emacs-orgmode, Rainer Stengele

>>>>> Carsten Dominik writes:

> I think it would be OK to modify the indentation code to do the most
> useful thing in this case, which is indenting to under the list.  Is
> is OK to put the burden for terminating list by indentation on the
> user.  

I fear that by doing this modification, we're letting in again a
dreadful bug. Let me explain it.

This is not the most useful thing in this case, but the most
conservative one. This is needed when you want to correct indentation
of a region (or the whole buffer). If we turn the behavior the other
way, indenting the buffer will ruin parts of it, like before, as any
text beyond a list would go inside its last item, regardless of text
position.

And this is worse than having to cope with some rectangle selection,
because it would modify parts of buffer outside user's view. With the
current behavior, what's in stays in, and what's out stays out.

Another idea would be to slightly modify `org-paste-special' and
`org-yank' so anything yanked inside a list is automatically put
inside the item at point. The exact behavior of this has yet to be
defined, though.

Regards,

-- Nicolas

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Re: struggling with simple indentation (possible bug)
  2010-10-26 10:58         ` Nicolas Goaziou
  2010-10-26 12:25           ` Carsten Dominik
@ 2010-10-26 15:10           ` Anthony Lander
  2010-10-26 21:43             ` [patch] struggling with simple indentation Nicolas Goaziou
  1 sibling, 1 reply; 11+ messages in thread
From: Anthony Lander @ 2010-10-26 15:10 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode Mode

Hi Nicolas,

With regards to the discussion below, if I 'set org-list-ending-method  
to 'regex, it seems to get confused if there is a drawer between the  
headline and the first line of text, so pressing TAB with the cursor  
at the vertical bar in this example:

---->8-------
** Headline
:PROPERTIES:
:FOO: Bar
:END:
|
---->8-------

Does not indent to the position under the "H" in the headline. The TAB  
key silently does nothing. Same effect with the properties drawer  
folded. Is it possible to indent correctly, ignoring the drawer?

Thanks,

   -Anthony

On 10-Oct-26, at 6:58 AM, Nicolas Goaziou wrote:

> Hello,
>>>>>> Rainer Stengele writes:
>
>> Sometime I do save some an email body text under an org item.
>> Pasting the text under "item" leads to
>
>> * heading
>>  - item
>> E-Mail body text line1
>> E-Mail body text line2
>> ...
>
>> Now I cannot use C-j of course. How do I easily get
>
>> * heading
>>  - item
>>    E-Mail body text line1
>>    E-Mail body text line2
>>    ...
>
> There is no way for Org to guess what you have in mind here (and this
> is why I don't like that much the "indent" method in
> `org-list-ending-method').
>
> In your situation, I would use C-x r o with an adequate rectangle
> selection. After all, we are _also_ in Emacs.
>
> Regards,
>
> -- Nicolas
>
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

		

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [patch] struggling with simple indentation
  2010-10-26 15:10           ` Re: struggling with simple indentation (possible bug) Anthony Lander
@ 2010-10-26 21:43             ` Nicolas Goaziou
  0 siblings, 0 replies; 11+ messages in thread
From: Nicolas Goaziou @ 2010-10-26 21:43 UTC (permalink / raw)
  To: Anthony Lander; +Cc: emacs-orgmode Mode




[-- Attachment #2: Type: text/plain, Size: 832 bytes --]

Hello,

>>>>> Anthony Lander writes:

> With regards to the discussion below, if I set
> org-list-ending-method to 'regex

The correct value is 'regexp.

> it seems to get confused if there is a drawer between the headline
> and the first line of text, so pressing TAB with the cursor at the
> vertical bar in this example:

----> 8-------
> ** Headline 
> :PROPERTIES:
> :FOO:  Bar
> :END:
> |
----> 8-------

> Does not indent to the position under the "H" in the headline. The
> TAB key silently does nothing. Same effect with the properties
> drawer folded. Is it possible to indent correctly, ignoring the
> drawer?

Actually, this has nothing to do with the value of
org-list-ending-method, but I think you are right, indentation should
ignore drawers.

Here is a patch to do so. Does it work for you ?

Regards,

-- Nicolas


[-- Attachment #3: 0001-indentation-lines-outside-of-drawers-ignore-indentat.patch --]
[-- Type: text/plain, Size: 1945 bytes --]

From 8aa0a33e36be4593ad605d9a3c283942a275e580 Mon Sep 17 00:00:00 2001
From: Nicolas Goaziou <n.goaziou@gmail.com>
Date: Tue, 26 Oct 2010 23:34:49 +0200
Subject: [PATCH] indentation: lines outside of drawers ignore indentation of drawers

* org.el (org-indent-line-function): Ignore drawers above the current
  line when indenting
---
 lisp/org.el |   13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index c4c64ee..edc0b74 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -18704,7 +18704,7 @@ which make use of the date at the cursor."
       (beginning-of-line 0)
       (while (and (not (bobp))
 		  ;; skip comments, verbatim, empty lines, tables,
-		  ;; inline tasks
+		  ;; inline tasks, and lists
 		  (or (looking-at "[ \t]*[\n:#|]")
 		      (and (org-in-item-p) (goto-char (org-list-top-point)))
 		      (and (not inline-task-p)
@@ -18714,8 +18714,11 @@ which make use of the date at the cursor."
       		  (not (looking-at org-drawer-regexp)))
       	(beginning-of-line 0))
       (cond
-       ;; There was an heading above.
-       ((looking-at "\\*+[ \t]+")
+       ;; There was an heading or the end of a drawer above.
+       ((or (looking-at "\\*+[ \t]+")
+	    (and (looking-at "[ \t]*:END:")
+		 (ignore-errors (org-back-to-heading 'invisible-ok))
+		 (looking-at "\\*+[ \t]+")))
 	(if (not org-adapt-indentation)
 	    (setq column 0)
 	  (goto-char (match-end 0))
@@ -18724,10 +18727,6 @@ which make use of the date at the cursor."
        ((looking-at org-drawer-regexp)
 	(goto-char (1- (match-beginning 1)))
 	(setq column (current-column)))
-       ;; The drawer had ended: indent like its :END: line.
-       ((looking-at "\\([ \t]*\\):END:")
-	(goto-char (match-end 1))
-	(setq column (current-column)))
        ;; Else, nothing noticeable found: get indentation and go on.
        (t (setq column (org-get-indentation))))))
     (goto-char pos)
-- 
1.7.3.2


[-- Attachment #4: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2010-10-26 21:44 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-25 12:35 struggling with simple indentation Rainer Stengele
2010-10-25 17:06 ` Nicolas Goaziou
2010-10-26  8:45   ` Rainer Stengele
2010-10-26  9:05     ` Nicolas Goaziou
2010-10-26  9:06     ` Nicolas Goaziou
2010-10-26 10:09       ` Rainer Stengele
2010-10-26 10:58         ` Nicolas Goaziou
2010-10-26 12:25           ` Carsten Dominik
2010-10-26 13:12             ` Nicolas Goaziou
2010-10-26 15:10           ` Re: struggling with simple indentation (possible bug) Anthony Lander
2010-10-26 21:43             ` [patch] struggling with simple indentation Nicolas Goaziou

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).