emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [BUG/PATCH] Set fill-indent-according-to-mode to nil in Org buffers
@ 2011-01-21 10:47 Lawrence Mitchell
  2011-01-21 13:34 ` Nicolas Goaziou
  0 siblings, 1 reply; 5+ messages in thread
From: Lawrence Mitchell @ 2011-01-21 10:47 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Lawrence Mitchell

* lisp/org.el (org-mode): Locally set `fill-indent-according-to-mode'
to nil.

`org-adaptive-fill-function' attempts to correctly pick up a fill
prefix for hand-indented paragraphs and lists.  This is defeated by
the indentation code, which does not recognise sublists correctly and
gets the indentation wrong.  By setting
`fill-indent-according-to-mode' to nil, we tell Emacs' filling code to
pay attention to `adaptive-fill-prefix' rather than using
`indent-line-function'.

This is not a perfect solution, since refilling a list entry still
does not work correctly unless the entire item is on a single line.
---
The filling code is a maze of twisty passages all alike, so I don't
really understand what's going on.  The problem is demonstrated with
auto-fill-mode on when typing sublist entries that wrap over more than
a single line

#+begin_src org
* Header
- List
  + Sublist entry with lots and lots and lots and lots of text is wrapped
  like this
#+end_src org
And "like this" is incorrectly considered to be be part of the "List"
entry, rather than the "Sublist" entry.

This change fixes this problem for auto-fill-mode wrapping, but it
doesn't work correctly for refilling, for reasons that are unclear to
me.

Cheers,
Lawrence


 lisp/org.el |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index fcdf245..268223b 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -4716,6 +4716,7 @@ The following commands are available:
   ;; Paragraphs and auto-filling
   (org-set-autofill-regexps)
   (setq indent-line-function 'org-indent-line-function)
+  (set (make-local-variable 'fill-indent-according-to-mode) nil)
   (org-update-radio-target-regexp)
   ;; Beginning/end of defun
   (org-set-local 'beginning-of-defun-function 'org-beginning-of-defun)
-- 
1.7.4.rc1.7.g2cf08

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

* Re: [BUG/PATCH] Set fill-indent-according-to-mode to nil in Org buffers
  2011-01-21 10:47 [BUG/PATCH] Set fill-indent-according-to-mode to nil in Org buffers Lawrence Mitchell
@ 2011-01-21 13:34 ` Nicolas Goaziou
  2011-01-21 14:21   ` Lawrence Mitchell
  0 siblings, 1 reply; 5+ messages in thread
From: Nicolas Goaziou @ 2011-01-21 13:34 UTC (permalink / raw)
  To: Lawrence Mitchell; +Cc: emacs-orgmode

Hello,

> This is defeated by the indentation code, which does not recognise
> sublists correctly and gets the indentation wrong. 

Would you mind elaborating? I fail to see where the indentation code
has some problem recognizing lists.

> By setting `fill-indent-according-to-mode' to nil, we tell Emacs'
> filling code to pay attention to `adaptive-fill-prefix' rather than
> using `indent-line-function'.

Not using `org-indent-line-function' sounds like a very bad idea to
me. Before ignoring this function, perhaps we could try to see what is
wrong with it.

> This is not a perfect solution, since refilling a list entry still
> does not work correctly unless the entire item is on a single line.

Huh? Again, could you provide an example, please?

> --- The filling code is a maze of twisty passages all alike, so I
> don't really understand what's going on. The problem is demonstrated
> with auto-fill-mode on when typing sublist entries that wrap over
> more than a single line

> #+begin_src org 
> * Header - List 
> + Sublist entry with lots and lots and lots and lots of text is
>    wrapped
> like this
> #+end_src org

>  And "like this" is incorrectly considered to be be part of the
> "List" entry, rather than the "Sublist" entry.

If "like this" is like this (!), then it _isn't_ part of the list. So
it is correctly considered outside of the list. Or am I missing the
point?

Regards,

-- Nicolas

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

* Re: [BUG/PATCH] Set fill-indent-according-to-mode to nil in Org buffers
  2011-01-21 13:34 ` Nicolas Goaziou
@ 2011-01-21 14:21   ` Lawrence Mitchell
  2011-01-21 16:00     ` Nicolas Goaziou
  0 siblings, 1 reply; 5+ messages in thread
From: Lawrence Mitchell @ 2011-01-21 14:21 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Nicolas Goaziou

Nicolas Goaziou wrote:
> Hello,

>> This is defeated by the indentation code, which does not recognise
>> sublists correctly and gets the indentation wrong.

> Would you mind elaborating? I fail to see where the indentation code
> has some problem recognizing lists.

Hopefully the example below clears things up a bit.

>> By setting `fill-indent-according-to-mode' to nil, we tell Emacs'
>> filling code to pay attention to `adaptive-fill-prefix' rather than
>> using `indent-line-function'.

> Not using `org-indent-line-function' sounds like a very bad idea to
> me. Before ignoring this function, perhaps we could try to see what is
> wrong with it.

>> This is not a perfect solution, since refilling a list entry still
>> does not work correctly unless the entire item is on a single line.

> Huh? Again, could you provide an example, please?

emacs -Q

C-x C-f $TMP/foo.org

M-: (erase-buffer) RET

M-x auto-fill-mode RET

M-: (insert "* Header\n- List entry\n  - Sublist entry") RET

Now type some more text so that the sublist entry line goes past
the fill column.  Note where the line-wrapping puts the
continuation of the sublist entry:

1 | * Header
2 | - List entry
3 |   - Sublist entry here we have some more text to make the line very
4 |   very long and trigger line-wrapping.

So the text on line 4 is considered to be part of the sublist
entry, while I would expect it to be so (it would have been if
auto-fill-mode were off).

If fill-indent-according-to-mode is set to nil then doing the
same thing leads to:

1 | * Header
2 | - List entry
3 |   - Sublist entry here we have some more text to make the line very
4 |     very long and trigger line-wrapping.

Notice how in this case the continuation of the sublist entry is
correct.

Furthermore, if you've formatted the document as in the second
example by hand, but fill-indent-according-to-mode is t, and you
hit M-q on the sublist entry, the indentation of line 4 is
changed from 4 spaces to 2 spaces.  This changes line 4 from
being part of the sublist entry to being part of the list entry
from line 2.

Hope this clarifies things.

Cheers,

Lawrence
-- 
Lawrence Mitchell <wence@gmx.li>

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

* Re: Re: [BUG/PATCH] Set fill-indent-according-to-mode to nil in Org buffers
  2011-01-21 14:21   ` Lawrence Mitchell
@ 2011-01-21 16:00     ` Nicolas Goaziou
  2011-01-21 16:09       ` Lawrence Mitchell
  0 siblings, 1 reply; 5+ messages in thread
From: Nicolas Goaziou @ 2011-01-21 16:00 UTC (permalink / raw)
  To: Lawrence Mitchell; +Cc: emacs-orgmode

>>>>> Lawrence Mitchell writes:

> Hopefully the example below clears things up a bit.

I cannot reproduce it, even when following your steps.

Regards,

-- Nicolas

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

* Re: [BUG/PATCH] Set fill-indent-according-to-mode to nil in Org buffers
  2011-01-21 16:00     ` Nicolas Goaziou
@ 2011-01-21 16:09       ` Lawrence Mitchell
  0 siblings, 0 replies; 5+ messages in thread
From: Lawrence Mitchell @ 2011-01-21 16:09 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Nicolas Goaziou

Nicolas Goaziou wrote:
>>>>>> Lawrence Mitchell writes:

>> Hopefully the example below clears things up a bit.

> I cannot reproduce it, even when following your steps.

This would appear to be due to driver error on my part.  My
.emacs sets fill-indent-according-to-mode to t, whereas by
default it is nil.  So to reproduce, follow my recipe and add M-:
(setq fill-indent-according-to-mode t) RET after opening the
org-mode buffer.

Given that the default value of fill-indent-according-to-mode
does /not/ cause a problem, maybe there's no reason to explicitly
set it to nil in org-mode.  I'll leave others to decide.

Cheers,

Lawrence

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

end of thread, other threads:[~2011-01-21 16:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-21 10:47 [BUG/PATCH] Set fill-indent-according-to-mode to nil in Org buffers Lawrence Mitchell
2011-01-21 13:34 ` Nicolas Goaziou
2011-01-21 14:21   ` Lawrence Mitchell
2011-01-21 16:00     ` Nicolas Goaziou
2011-01-21 16:09       ` Lawrence Mitchell

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