emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* indentation for section headings vs bulleted lists
@ 2011-02-18  6:39 Linus Arver
  2011-02-18  8:52 ` Bastien
  2011-02-18 18:18 ` Darlan Cavalcante Moreira
  0 siblings, 2 replies; 15+ messages in thread
From: Linus Arver @ 2011-02-18  6:39 UTC (permalink / raw)
  To: emacs-orgmode

Hello, I have

#+STARTUP: indent

in my .org file. I notice that section headings get indented like this:

* blah blah blah blah
  blah blah blah blah
  blah blah blah blah
** blah blah blah blah
   blah blah blah blah
   blah blah blah blah

This is very nice. But regular bulleted lists are indented like this:

- blah blah blah blah
blah blah blah blah
blah blah blah blah
 - blah blah blah blah
 blah blah blah blah
 blah blah blah blah

How do I make it so that bulleted lists are indented just like the section headings?

-Linus

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

* Re: indentation for section headings vs bulleted lists
  2011-02-18  6:39 indentation for section headings vs bulleted lists Linus Arver
@ 2011-02-18  8:52 ` Bastien
  2011-02-19  2:34   ` Linus Arver
  2011-02-18 18:18 ` Darlan Cavalcante Moreira
  1 sibling, 1 reply; 15+ messages in thread
From: Bastien @ 2011-02-18  8:52 UTC (permalink / raw)
  To: Linus Arver; +Cc: emacs-orgmode

Hi Linus,

Linus Arver <linusarver@gmail.com> writes:

> This is very nice. But regular bulleted lists are indented like this:
>
> - blah blah blah blah
> blah blah blah blah
> blah blah blah blah
>  - blah blah blah blah
>  blah blah blah blah
>  blah blah blah blah

I cannot reproduce this with latest git Org.  What Org version are you
running?

-- 
 Bastien

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

* Re: indentation for section headings vs bulleted lists
  2011-02-18  6:39 indentation for section headings vs bulleted lists Linus Arver
  2011-02-18  8:52 ` Bastien
@ 2011-02-18 18:18 ` Darlan Cavalcante Moreira
  2011-02-19  2:46   ` Linus Arver
  1 sibling, 1 reply; 15+ messages in thread
From: Darlan Cavalcante Moreira @ 2011-02-18 18:18 UTC (permalink / raw)
  To: Linus Arver; +Cc: emacs-orgmode


In fact, lists are indented like this, but indentation has meaning.

I remember some recent changes announced here in the mailing list to how
lists are handled in org that made lists more powerful. It seems now that
if some text is part or not of the list is controlled by
indentation. Therefore, if you write
#+begin_src org
- blah blah blah blah
  bleh bleh bleh bleh
blih blih blih blih
#+end_src
then "bleh bleh bleh bleh" is part of the list (as if it were in the same
line of "blah blah blah blah"), but not "blih blih blih blih". You can test
this by exporting and seeing the result.

--
Darlan

At Thu, 17 Feb 2011 22:39:39 -0800,
Linus Arver <linusarver@gmail.com> wrote:
> 
> Hello, I have
> 
> #+STARTUP: indent
> 
> in my .org file. I notice that section headings get indented like this:
> 
> * blah blah blah blah
>   blah blah blah blah
>   blah blah blah blah
> ** blah blah blah blah
>    blah blah blah blah
>    blah blah blah blah
> 
> This is very nice. But regular bulleted lists are indented like this:
> 
> - blah blah blah blah
> blah blah blah blah
> blah blah blah blah
>  - blah blah blah blah
>  blah blah blah blah
>  blah blah blah blah
> 
> How do I make it so that bulleted lists are indented just like the section headings?
> 
> -Linus
> 
> _______________________________________________
> 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] 15+ messages in thread

* Re: indentation for section headings vs bulleted lists
  2011-02-18  8:52 ` Bastien
@ 2011-02-19  2:34   ` Linus Arver
  2011-02-19  9:35     ` Bastien
  0 siblings, 1 reply; 15+ messages in thread
From: Linus Arver @ 2011-02-19  2:34 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode

On Fri, Feb 18, 2011 at 09:52:14AM +0100, Bastien wrote:
> Hi Linus,
> 
> Linus Arver <linusarver@gmail.com> writes:
> 
> > This is very nice. But regular bulleted lists are indented like this:
> >
> > - blah blah blah blah
> > blah blah blah blah
> > blah blah blah blah
> >  - blah blah blah blah
> >  blah blah blah blah
> >  blah blah blah blah
> 
> I cannot reproduce this with latest git Org.  What Org version are you
> running?
> 
> -- 
>  Bastien

I'm running emacs-org-mode 7.4.
(http://aur.archlinux.org/packages.php?ID=18206).

-Linus

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

* Re: indentation for section headings vs bulleted lists
  2011-02-18 18:18 ` Darlan Cavalcante Moreira
@ 2011-02-19  2:46   ` Linus Arver
  0 siblings, 0 replies; 15+ messages in thread
From: Linus Arver @ 2011-02-19  2:46 UTC (permalink / raw)
  To: Darlan Cavalcante Moreira; +Cc: emacs-orgmode

On Fri, Feb 18, 2011 at 03:18:38PM -0300, Darlan Cavalcante Moreira wrote:
> 
> In fact, lists are indented like this, but indentation has meaning.
> 
> I remember some recent changes announced here in the mailing list to how
> lists are handled in org that made lists more powerful. It seems now that
> if some text is part or not of the list is controlled by
> indentation. Therefore, if you write
> #+begin_src org
> - blah blah blah blah
>   bleh bleh bleh bleh
> blih blih blih blih
> #+end_src
> then "bleh bleh bleh bleh" is part of the list (as if it were in the same
> line of "blah blah blah blah"), but not "blih blih blih blih". You can test
> this by exporting and seeing the result.
> 

I think I failed to explain the problem more accurately. In my original
post, I stated the following behavior:

* blah blah blah blah
  blah blah blah blah
  blah blah blah blah
** blah blah blah blah
   blah blah blah blah
   blah blah blah blah
- blah blah blah blah
blah blah blah blah
blah blah blah blah
 - blah blah blah blah
 blah blah blah blah
 blah blah blah blah

In the above example, there are *only* 4 physical lines of text. That
is, there are only 4 newline characters in the actual text file. The

#+STARTUP: indent

property, from what I understand, merely takes the 4 actual lines and
"soft wraps" them intelligently, so as to create a series of *fake*
newlines and indents, to give the illusion of multiple, neatly-indented
lines.

My problem was that org-mode handles section headings (*) properly, but
not bulleted list items (-) for some reason, choosing to indent on the
location of the bullet (-) itself, and not the beginning of the actual
leading text. I.e., instead of

 - blah blah blah blah    <--- a *single* line
 blah blah blah blah
 blah blah blah blah
   - blah blah blah blah  <--- another single line
   blah blah blah blah
   blah blah blah blah

I want org-mode to indent it like this:

 - blah blah blah blah
   blah blah blah blah
   blah blah blah blah
   - blah blah blah blah
     blah blah blah blah
     blah blah blah blah

Again, this is a soft wrap issue. I'll try to use the latest git version
of org-mode and see if that helps.

-Linus

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

* Re: indentation for section headings vs bulleted lists
  2011-02-19  2:34   ` Linus Arver
@ 2011-02-19  9:35     ` Bastien
  2011-02-20  7:22       ` Linus Arver
  0 siblings, 1 reply; 15+ messages in thread
From: Bastien @ 2011-02-19  9:35 UTC (permalink / raw)
  To: Linus Arver; +Cc: emacs-orgmode

Hi Linus,

Linus Arver <linusarver@gmail.com> writes:

> I'm running emacs-org-mode 7.4.
> (http://aur.archlinux.org/packages.php?ID=18206).

There has been important changes to the way Org handles lists in the git
repo.  You can either check them but cloning this repo or wait for the
next release.

HTH,

-- 
 Bastien

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

* Re: indentation for section headings vs bulleted lists
  2011-02-19  9:35     ` Bastien
@ 2011-02-20  7:22       ` Linus Arver
  2011-02-20 12:19         ` Nicolas
  0 siblings, 1 reply; 15+ messages in thread
From: Linus Arver @ 2011-02-20  7:22 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode

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

On Sat, Feb 19, 2011 at 10:35:11AM +0100, Bastien wrote:
> Hi Linus,
> 
> Linus Arver <linusarver@gmail.com> writes:
> 
> > I'm running emacs-org-mode 7.4.
> > (http://aur.archlinux.org/packages.php?ID=18206).
> 
> There has been important changes to the way Org handles lists in the git
> repo.  You can either check them but cloning this repo or wait for the
> next release.
> 
> HTH,
> 
> -- 
>  Bastien

I've switched to the git version of org-mode, and there is no change in
behavior. I am including a link to a screenshot, with a very good
example of the behavior (with physical line numbers showing), to see if
anyone can reproduce the behavior on their system.

Screenshot: http://img593.imageshack.us/i/20110219231411681x766sc.png/

Again, I'm very curious why org-mode's indenting code treats bulleted
lists differently than section headings.

I'm also attaching the raw .org file with this message as a reference.

-Linus

[-- Attachment #2: sample.org --]
[-- Type: text/plain, Size: 1966 bytes --]

#+STARTUP: indent

- asd fas fdsf sdf sdfasdf sadf sadf adf asdf sadf sadf dsf sf dsf dsaf asdf dsaf df adf dsaf dsaf dfa df asdf dsf adsf dsf dsf adsf dasf adsf dfa sdf dsaf dsaf dsa dfa fd fdsa dsf saf dasf df df dsf dsf sdf ds fds d fdf dsaf dsf dsf dsf df
  - asd fas fdsf sdf sdfasdf sadf sadf adf asdf sadf sadf dsf sf dsf dsaf asdf dsaf df adf dsaf dsaf dfa df asdf dsf adsf dsf dsf adsf dasf adsf dfa sdf dsaf dsaf dsa dfa fd fdsa dsf saf dasf df df dsf dsf sdf ds fds d fdf dsaf dsf dsf dsf df
    - asd fas fdsf sdf sdfasdf sadf sadf adf asdf sadf sadf dsf sf dsf dsaf asdf dsaf df adf dsaf dsaf dfa df asdf dsf adsf dsf dsf adsf dasf adsf dfa sdf dsaf dsaf dsa dfa fd fdsa dsf saf dasf df df dsf dsf sdf ds fds d fdf dsaf dsf dsf dsf df
      - asd fas fdsf sdf sdfasdf sadf sadf adf asdf sadf sadf dsf sf dsf dsaf asdf dsaf df adf dsaf dsaf dfa df asdf dsf adsf dsf dsf adsf dasf adsf dfa sdf dsaf dsaf dsa dfa fd fdsa dsf saf dasf df df dsf dsf sdf ds fds d fdf dsaf dsf dsf dsf df

* asd fas fdsf sdf sdfasdf sadf sadf adf asdf sadf sadf dsf sf dsf dsaf asdf dsaf df adf dsaf dsaf dfa df asdf dsf adsf dsf dsf adsf dasf adsf dfa sdf dsaf dsaf dsa dfa fd fdsa dsf saf dasf df df dsf dsf sdf ds fds d fdf dsaf dsf dsf dsf df
** asd fas fdsf sdf sdfasdf sadf sadf adf asdf sadf sadf dsf sf dsf dsaf asdf dsaf df adf dsaf dsaf dfa df asdf dsf adsf dsf dsf adsf dasf adsf dfa sdf dsaf dsaf dsa dfa fd fdsa dsf saf dasf df df dsf dsf sdf ds fds d fdf dsaf dsf dsf dsf df
*** asd fas fdsf sdf sdfasdf sadf sadf adf asdf sadf sadf dsf sf dsf dsaf asdf dsaf df adf dsaf dsaf dfa df asdf dsf adsf dsf dsf adsf dasf adsf dfa sdf dsaf dsaf dsa dfa fd fdsa dsf saf dasf df df dsf dsf sdf ds fds d fdf dsaf dsf dsf dsf df
**** asd fas fdsf sdf sdfasdf sadf sadf adf asdf sadf sadf dsf sf dsf dsaf asdf dsaf df adf dsaf dsaf dfa df asdf dsf adsf dsf dsf adsf dasf adsf dfa sdf dsaf dsaf dsa dfa fd fdsa dsf saf dasf df df dsf dsf sdf ds fds d fdf dsaf dsf dsf dsf df

[-- Attachment #3: 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	[flat|nested] 15+ messages in thread

* Re: indentation for section headings vs bulleted lists
  2011-02-20  7:22       ` Linus Arver
@ 2011-02-20 12:19         ` Nicolas
  2011-02-20 12:39           ` Carsten Dominik
  2011-02-20 19:51           ` Linus Arver
  0 siblings, 2 replies; 15+ messages in thread
From: Nicolas @ 2011-02-20 12:19 UTC (permalink / raw)
  To: Linus Arver; +Cc: emacs-orgmode, Bastien

Hello,

Linus Arver <linusarver@gmail.com> writes:

> Again, I'm very curious why org-mode's indenting code treats bulleted
> lists differently than section headings.

This is due to a combination of org-indent-mode and visual-line-mode.
Actually, it's a a two-parts problem. 

Firstly, org-indent-mode only works by sections. That means the whole
section gets the same indent prefix, whatever can be inside. Thus, lists
cannot be treated differently for now.

Secondly, org-indent-mode is not indenting anything: it only fakes it.
While this is fine for headings, this causes problems with lists, which
are depending on real indentation.

Anyway, I'm on it. I'll post a patch as soon as I find and implement a
decent way to solve this.


Regards,

-- 
Nicolas

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

* Re: Re: indentation for section headings vs bulleted lists
  2011-02-20 12:19         ` Nicolas
@ 2011-02-20 12:39           ` Carsten Dominik
  2011-02-20 13:27             ` Nicolas
  2011-02-20 19:51           ` Linus Arver
  1 sibling, 1 reply; 15+ messages in thread
From: Carsten Dominik @ 2011-02-20 12:39 UTC (permalink / raw)
  To: Nicolas; +Cc: Linus Arver, emacs-orgmode, Bastien


On Feb 20, 2011, at 1:19 PM, Nicolas wrote:

> Hello,
>
> Linus Arver <linusarver@gmail.com> writes:
>
>> Again, I'm very curious why org-mode's indenting code treats bulleted
>> lists differently than section headings.
>
> This is due to a combination of org-indent-mode and visual-line-mode.
> Actually, it's a a two-parts problem.
>
> Firstly, org-indent-mode only works by sections. That means the whole
> section gets the same indent prefix, whatever can be inside. Thus,  
> lists
> cannot be treated differently for now.
>
> Secondly, org-indent-mode is not indenting anything: it only fakes it.
> While this is fine for headings, this causes problems with lists,  
> which
> are depending on real indentation.
>
> Anyway, I'm on it. I'll post a patch as soon as I find and implement a
> decent way to solve this.

Hi Nicolas,
while it might be posible to add additional line-prefix stuff to
plain lists, you need to be careful about performance.
I wrote several (I believe 4) different versions of
org-indent-mode before behavior was reasonably consistent
and fast enough.

Cheers

- Carsten

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

* Re: indentation for section headings vs bulleted lists
  2011-02-20 12:39           ` Carsten Dominik
@ 2011-02-20 13:27             ` Nicolas
  0 siblings, 0 replies; 15+ messages in thread
From: Nicolas @ 2011-02-20 13:27 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: Linus Arver, emacs-orgmode, Bastien

Hello,

Carsten Dominik <carsten.dominik@gmail.com> writes:

> while it might be posible to add additional line-prefix stuff to plain
> lists, you need to be careful about performance.

Yes, this is my main concern actually. When I speak about a "decent"
solution, I'm really thinking about a "sufficiently reactive" one,
provided such a thing exists.

As far as I can tell, line-prefix is fine as it is. Lists just need to
take it as real indentation before processing. Alas, wrap-prefix is the
real problem.

A solution would be to distinguish if org-indent-refresh-section is
called with point in a list or not. In the former case, it would skip
lists when changing warp-prefix in the section. In the latter situation,
it would only set warp-prefix for the list at point.

But then, hooks like org-after-demote-entry-hook would need to call
org-indent-refresh-section with an argument telling it to redefine
warp-prefix for everything in section, lists included. After all, a
small delay is acceptable for interactive use.

Does it sound "decent"?


Regards,

-- 
Nicolas

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

* Re: indentation for section headings vs bulleted lists
  2011-02-20 12:19         ` Nicolas
  2011-02-20 12:39           ` Carsten Dominik
@ 2011-02-20 19:51           ` Linus Arver
  2011-02-20 23:26             ` [PATCH] " Nicolas
  1 sibling, 1 reply; 15+ messages in thread
From: Linus Arver @ 2011-02-20 19:51 UTC (permalink / raw)
  To: n.goaziou, Bastien, emacs-orgmode

On Sun, Feb 20, 2011 at 01:19:43PM +0100, Nicolas wrote:
> Firstly, org-indent-mode only works by sections. That means the whole
> section gets the same indent prefix, whatever can be inside. Thus, lists
> cannot be treated differently for now.

While I am not technically knowledgeable with org-mode's internals, it
surprises me that lists and section headings are treated differently for
org-indent-mode. I guess I won't be able to use lists for a while...
(I suppose the other option is to use real indentation, manually, to
break up a long list line into smaller chunks, but that solution to me
is just ugly and hacky. It would be great to get uniform behavior for
both sections as well as lists.)

> Secondly, org-indent-mode is not indenting anything: it only fakes it.
> While this is fine for headings, this causes problems with lists, which
> are depending on real indentation.

I did not know that lists were dependant on real indentation. Now I
know.

> Anyway, I'm on it. I'll post a patch as soon as I find and implement a
> decent way to solve this.
> 
> 
> Regards,
> 
> -- 
> Nicolas

Thanks for taking up the challenge, Nicolas!

-Linus

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

* Re: [PATCH] indentation for section headings vs bulleted lists
  2011-02-20 19:51           ` Linus Arver
@ 2011-02-20 23:26             ` Nicolas
  2011-02-21  1:04               ` Linus Arver
  0 siblings, 1 reply; 15+ messages in thread
From: Nicolas @ 2011-02-20 23:26 UTC (permalink / raw)
  To: Linus Arver; +Cc: emacs-orgmode, Bastien

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

Hello,

Here is an attempt to solve the problem at hand.

Linus, would you mind testing it and reporting back?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch to integrate lists with org-indent-mode --]
[-- Type: text/x-patch, Size: 10938 bytes --]

From 77aad13b9a322032763148b17dd9cb3073bdbf23 Mon Sep 17 00:00:00 2001
From: Nicolas Goaziou <n.goaziou@gmail.com>
Date: Sun, 20 Feb 2011 13:44:00 +0100
Subject: [PATCH] Integrate lists with org-indent-mode and visual-line-mode

* lisp/org-list.el (org-list-insert-item): keep prefix properties when
  inserting a new item.
  (org-list-struct-apply-struct): keep prefix properties when
  modifying an item.
* lisp/org-indent.el (org-indent-mode): promoting and demoting should
  refresh subtree.
  (org-indent-add-properties): Add lists support. Refactor and comment
  code.
  (org-indent-refresh-subtree): No need to remove properties before
  refreshing. Also, make sure beg is at beginning of line.
  (org-indent-refresh-to, org-indent-refresh-section): Refactor. No
  need to remove properties before refreshing either.
---
 lisp/org-indent.el |  132 ++++++++++++++++++++++-----------------------------
 lisp/org-list.el   |   18 ++++++-
 2 files changed, 73 insertions(+), 77 deletions(-)

diff --git a/lisp/org-indent.el b/lisp/org-indent.el
index a177a6f..4411cd2 100644
--- a/lisp/org-indent.el
+++ b/lisp/org-indent.el
@@ -39,6 +39,7 @@
   (require 'cl))
 
 (defvar org-inlinetask-min-level)
+(declare-function org-in-item-p "org-list" ())
 (declare-function org-inlinetask-get-task-level "org-inlinetask" ())
 (declare-function org-inlinetask-in-task-p "org-inlinetask" ())
 
@@ -161,13 +162,12 @@ FIXME:  How to update when broken?"
     (add-to-list 'buffer-substring-filters
 		 'org-indent-remove-properties-from-string)
     (org-add-hook 'org-after-demote-entry-hook
-		  'org-indent-refresh-section nil 'local)
+		  'org-indent-refresh-subtree nil 'local)
     (org-add-hook 'org-after-promote-entry-hook
-		  'org-indent-refresh-section nil 'local)
+		  'org-indent-refresh-subtree nil 'local)
     (org-add-hook 'org-font-lock-hook
 		  'org-indent-refresh-to nil 'local)
-    (and font-lock-mode (org-restart-font-lock))
-    )
+    (and font-lock-mode (org-restart-font-lock)))
    (t
     ;; mode was turned off (or we refused to turn it on)
     (save-excursion
@@ -181,9 +181,9 @@ FIXME:  How to update when broken?"
 	      (delq 'org-indent-remove-properties-from-string
 		    buffer-substring-filters))
 	(remove-hook 'org-after-promote-entry-hook
-		     'org-indent-refresh-section 'local)
+		     'org-indent-refresh-subtree 'local)
 	(remove-hook 'org-after-demote-entry-hook
-		     'org-indent-refresh-section 'local)
+		     'org-indent-refresh-subtree 'local)
 	(and font-lock-mode (org-restart-font-lock))
 	(redraw-display))))))
 
@@ -222,82 +222,66 @@ useful to make it ever so slightly different."
 
 (defun org-indent-add-properties (beg end)
   "Add indentation properties between BEG and END.
-Assumes that BEG is at the beginning of a line."
+Assume BEG is at an headline, inline task, or at beginning of buffer."
   (let* ((inhibit-modification-hooks t)
 	 (inlinetaskp (featurep 'org-inlinetask))
-	 (get-real-level (lambda (pos lvl)
-			   (save-excursion
-			     (goto-char pos)
-			     (if (and inlinetaskp (org-inlinetask-in-task-p))
-				 (org-inlinetask-get-task-level)
-			       lvl))))
-	 (b beg)
-	 (e end)
-	 (level 0)
-	 (n 0)
-	 exit nstars)
+	 (m end))
     (with-silent-modifications
+      ;; 1. Starting from END, move to each headline and inline task,
+      ;;    and set prefixes point and the headline/inline task below
+      ;;    (saved in M). `line-prefix' property is only set on inner
+      ;;    part of that area, not on headlines.
       (save-excursion
+	(goto-char end)
+	(while (re-search-backward org-indent-outline-re beg 'move)
+	  (let ((pf (aref org-indent-strings
+			  (if (and inlinetaskp (org-inlinetask-at-task-p))
+			      (1+ (org-inlinetask-get-task-level))
+			    (1+ (org-current-level))))))
+	    (add-text-properties (point) m `(wrap-prefix ,pf))
+	    (add-text-properties (point-at-eol) m `(line-prefix ,pf))
+	    (setq m (point))))
+	;; Special case for area before first headline.
+	(when (bobp)
+	  (add-text-properties (point) m '(wrap-prefix nil line-prefix nil)))
+	;; 2. Set `wrap-prefix' in lists between BEG and END. For each
+	;;    item, length of prefix is the sum of length of
+	;;    `line-prefix', indentation and size of bullet.
 	(goto-char beg)
-	(while (not exit)
-	  (setq e end)
-	  (if (not (re-search-forward org-indent-outline-re nil t))
-	      (setq e (point-max) exit t)
-	    (setq e (match-beginning 0))
-	    (if (>= e end) (setq exit t))
-	    (unless (and inlinetaskp (org-inlinetask-in-task-p))
-	      (setq level (- (match-end 0) (match-beginning 0) 1)))
-	    (setq nstars (* (1- (funcall get-real-level e level))
-			    (1- org-indent-indentation-per-level)))
-	    (add-text-properties
-	     (point-at-bol) (point-at-eol)
-	     (list 'line-prefix
-		   (aref org-indent-stars nstars)
-		   'wrap-prefix
-		   (aref org-indent-strings
-			 (* (funcall get-real-level e level)
-			    org-indent-indentation-per-level)))))
-	  (when (> e b)
-	    (add-text-properties
-	     b  e (list 'line-prefix (aref org-indent-strings n)
-			'wrap-prefix (aref org-indent-strings n))))
-	  (setq b (1+ (point-at-eol))
-		n (* (funcall get-real-level b level)
-		     org-indent-indentation-per-level)))))))
+	(while (org-list-search-forward (org-item-beginning-re) end t)
+	  (let ((struct (org-list-struct)))
+	    (mapc (lambda (itm)
+		    (let ((pf (aref org-indent-strings
+				    (+ (length (get-text-property
+						(car itm) 'line-prefix))
+				       (nth 1 itm)
+				       (length (nth 2 itm))))))
+		      (add-text-properties (car itm) (1- (nth 6 itm))
+					   `(wrap-prefix ,pf))))
+		  struct)
+	    (goto-char (org-list-get-bottom-point struct))))))))
 
 (defvar org-inlinetask-min-level)
 (defun org-indent-refresh-section ()
-  "Refresh indentation properties in the current outline section.
-Point is assumed to be at the beginning of a headline."
+  "Refresh indentation properties between point and end next outline section."
   (interactive)
   (when org-indent-mode
-    (let (beg end)
-      (save-excursion
-	(when (ignore-errors (let ((outline-regexp (format "\\*\\{1,%s\\}[ \t]+"
-				(if (featurep 'org-inlinetask)
-				    (1- org-inlinetask-min-level)
-				  ""))))
-			       (org-back-to-heading)))
-	  (setq beg (point))
-	  (setq end (or (save-excursion (or (outline-next-heading) (point)))))
-	  (org-indent-remove-properties beg end)
-	  (org-indent-add-properties beg end))))))
+    (save-excursion
+      (org-with-limited-levels
+       (let ((beg (or (ignore-errors (org-back-to-heading))
+		      (point-min)))
+	     (end (progn (outline-next-heading) (point))))
+	 (org-indent-add-properties beg end))))))
 
 (defun org-indent-refresh-to (limit)
-  "Refresh indentation properties in the current outline section.
-Point is assumed to be at the beginning of a headline."
+  "Refresh indentation properties in the current outline section."
   (interactive)
   (when org-indent-mode
-    (let ((beg (point)) (end limit))
-      (save-excursion
-	(and (ignore-errors (let ((outline-regexp (format "\\*\\{1,%s\\}[ \t]+"
-				(if (featurep 'org-inlinetask)
-				    (1- org-inlinetask-min-level)
-				  ""))))
-			      (org-back-to-heading)))
-	     (setq beg (point))))
-      (org-indent-remove-properties beg end)
-      (org-indent-add-properties beg end)))
+    (save-excursion
+      (org-with-limited-levels
+       (let ((beg (or (and (ignore-errors (org-back-to-heading)) (point))
+		     (point-min))))
+	(org-indent-add-properties beg limit)))))
   (goto-char limit))
 
 (defun org-indent-refresh-subtree ()
@@ -306,15 +290,13 @@ Point is assumed to be at the beginning of a headline."
   (interactive)
   (when org-indent-mode
     (save-excursion
-      (let (beg end)
-	(setq beg (point))
-	(setq end (save-excursion (org-end-of-subtree t t)))
-	(org-indent-remove-properties beg end)
-	(org-indent-add-properties beg end)))))
+      (org-with-limited-levels
+       (let ((beg (point-at-bol))
+	    (end (save-excursion (org-end-of-subtree t t))))
+	 (org-indent-add-properties beg end))))))
 
 (defun org-indent-refresh-buffer ()
-  "Refresh indentation properties in the current outline subtree.
-Point is assumed to be at the beginning of a headline."
+  "Refresh indentation properties in the current outline subtree."
   (interactive)
   (when org-indent-mode
     (org-indent-mode -1)
diff --git a/lisp/org-list.el b/lisp/org-list.el
index 4700477..8ffe4d0 100644
--- a/lisp/org-list.el
+++ b/lisp/org-list.el
@@ -1156,9 +1156,12 @@ This function modifies STRUCT."
     ;;    functions, position of point with regards to item start
     ;;    (BEFOREP), blank lines number separating items (BLANK-NB),
     ;;    position of split (POS) if we're allowed to (SPLIT-LINE-P).
+    ;;    Also, save prefix properties for `org-indent-mode'.
     (let* ((item (goto-char (org-list-get-item-begin)))
 	   (item-end (org-list-get-item-end item struct))
 	   (item-end-no-blank (org-list-get-item-end-before-blank item struct))
+	   (wrap (get-text-property (point) 'wrap-prefix))
+	   (line (get-text-property (point) 'line-prefix))
 	   (beforep (and (looking-at org-list-full-item-re)
 			 (<= pos (match-end 0))))
 	   (split-line-p (org-get-alist-option org-M-RET-may-split-line 'item))
@@ -1194,6 +1197,9 @@ This function modifies STRUCT."
       (goto-char item)
       (org-indent-to-column ind)
       (insert body)
+      (when (and (featurep 'org-indent) org-indent-mode)
+	(add-text-properties item (point)
+			     `(line-prefix ,line wrap-prefix ,wrap)))
       (insert item-sep)
       ;; 5. Add new item to STRUCT.
       (mapc (lambda (e)
@@ -1628,7 +1634,9 @@ Initial position of cursor is restored after the changes."
 		    (new-bul (org-list-bullet-string
 			      (org-list-get-bullet item struct)))
 		    (old-bul (org-list-get-bullet item old-struct))
-		    (new-box (org-list-get-checkbox item struct)))
+		    (new-box (org-list-get-checkbox item struct))
+		    (wrap (get-text-property (point) 'wrap-prefix))
+		    (line (get-text-property (point) 'line-prefix)))
 	       (looking-at org-list-full-item-re)
 	       ;; a. Replace bullet
 	       (unless (equal old-bul new-bul)
@@ -1652,7 +1660,13 @@ Initial position of cursor is restored after the changes."
 	       (unless (= new-ind old-ind)
 		 (delete-region (goto-char (point-at-bol))
 				(progn (skip-chars-forward " \t") (point)))
-		 (indent-to new-ind)))))))
+		 (indent-to new-ind))
+	       ;; d. If `org-indent-mode' is on, keep prefix
+	       ;;    properties.
+	       (when (and (featurep 'org-indent) org-indent-mode)
+		 (add-text-properties
+		  (point-at-bol) (point-at-eol)
+		  `(line-prefix ,line wrap-prefix ,wrap))))))))
     ;; 1. First get list of items and position endings. We maintain
     ;;    two alists: ITM-SHIFT, determining indentation shift needed
     ;;    at item, and END-POS, a pseudo-alist where key is ending
-- 
1.7.4.1


[-- Attachment #3: Type: text/plain, Size: 23 bytes --]


Regards,

-- 
Nicolas

[-- 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] 15+ messages in thread

* Re: [PATCH] indentation for section headings vs bulleted lists
  2011-02-20 23:26             ` [PATCH] " Nicolas
@ 2011-02-21  1:04               ` Linus Arver
  2011-02-21 10:59                 ` Giovanni Ridolfi
  0 siblings, 1 reply; 15+ messages in thread
From: Linus Arver @ 2011-02-21  1:04 UTC (permalink / raw)
  To: Nicolas; +Cc: emacs-orgmode

On Mon, Feb 21, 2011 at 12:26:30AM +0100, Nicolas wrote:
> Hello,
> 
> Here is an attempt to solve the problem at hand.
> 
> Linus, would you mind testing it and reporting back?
> 

Brilliant, I just applied your patch to the git version and everything
works nicely as I had hoped!

Thank you so much, Nicolas!

-Linus

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

* Re: Re: [PATCH] indentation for section headings vs bulleted lists
  2011-02-21  1:04               ` Linus Arver
@ 2011-02-21 10:59                 ` Giovanni Ridolfi
  2011-02-21 17:32                   ` Nicolas
  0 siblings, 1 reply; 15+ messages in thread
From: Giovanni Ridolfi @ 2011-02-21 10:59 UTC (permalink / raw)
  To: Nicolas, Linus Arver, Carsten Dominik; +Cc: emacs-orgmode

--- Lun 21/2/11, Linus Arver <linusarver@gmail.com> ha scritto:
> Da: Linus Arver <linusarver@gmail.com> Lunedì 21 febbraio 2011, 01:04
> On Mon, Feb 21, 2011 at 12:26:30AM
> +0100, Nicolas wrote:
> > Hello,
> > 
> > Here is an attempt to solve the problem at hand.
> > 
> > Linus, would you mind testing it and reporting back?
> > 
> 
> Brilliant, I just applied your patch to the git version and
> everything  works nicely as I had hoped!

In Linus's example file there was no heading, I think this is 
*not* a  "regular example".

------------------------- file from Linus ----
#+STARTUP: indent

- asd fas fdsf sdf sdfasdf sadf sadf 
  - asd fas fdsf sdf sdfasdf sadf sad

* asd fas fdsf sdf sdfasdf sadf sadf 
** asd fas fdsf sdf sdfasdf sadf sadf dasf df df dsf dsf sdf ds fds d fdf dsaf dsf dsf dsf df
----------------------------------------------------------

The manual states: " Within an entry of the outline tree,".

Nicolas, does this constrain still apply with the 'new' 
way of handling lists?

cheers,
Giovanni




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

* Re: [PATCH] indentation for section headings vs bulleted lists
  2011-02-21 10:59                 ` Giovanni Ridolfi
@ 2011-02-21 17:32                   ` Nicolas
  0 siblings, 0 replies; 15+ messages in thread
From: Nicolas @ 2011-02-21 17:32 UTC (permalink / raw)
  To: Giovanni Ridolfi; +Cc: Linus Arver, emacs-orgmode, Carsten Dominik

Hello,

Giovanni Ridolfi <giovanni.ridolfi@yahoo.it> writes:

> In Linus's example file there was no heading, I think this is 
> *not* a  "regular example".
>
> The manual states: " Within an entry of the outline tree,".
>
> Nicolas, does this constrain still apply with the 'new' 
> way of handling lists?

It should work anywhere in an outline tree and before first headline, if
that's your question. So there is no constrain on lists.

Please note that the patch isn't ready for submission yet. I'll include
some speed improvements (scanning every list in section every 0.2s sure
sounds a bit scary) and a bit of polishing a bit later.

Regards,

-- 
Nicolas

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

end of thread, other threads:[~2011-02-21 17:32 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-18  6:39 indentation for section headings vs bulleted lists Linus Arver
2011-02-18  8:52 ` Bastien
2011-02-19  2:34   ` Linus Arver
2011-02-19  9:35     ` Bastien
2011-02-20  7:22       ` Linus Arver
2011-02-20 12:19         ` Nicolas
2011-02-20 12:39           ` Carsten Dominik
2011-02-20 13:27             ` Nicolas
2011-02-20 19:51           ` Linus Arver
2011-02-20 23:26             ` [PATCH] " Nicolas
2011-02-21  1:04               ` Linus Arver
2011-02-21 10:59                 ` Giovanni Ridolfi
2011-02-21 17:32                   ` Nicolas
2011-02-18 18:18 ` Darlan Cavalcante Moreira
2011-02-19  2:46   ` Linus Arver

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