emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* org-fill-paragraph invoked on column 0
@ 2012-07-30 19:52 Michael Brand
  2012-07-30 21:49 ` Nicolas Goaziou
  0 siblings, 1 reply; 11+ messages in thread
From: Michael Brand @ 2012-07-30 19:52 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Org Mode

Hi Nicolas

Before

    commit b04f9e32680e01ef17ed813940c0c58491f0d9aa
    Author: Nicolas Goaziou <n.goaziou@gmail.com>
    Date:   Sat Jul 28 10:24:08 2012 +0200

        `org-fill-paragraph' is backed up by Org Element

I could move up and down through the lines and fill list items with
M-q also when staying on column 0. Now I have to move right at least
until the item body starts which is less comfortable for me. Is there
a reason why this should not be possible any more between column 0 and
the item body start?

Michael

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

* Re: org-fill-paragraph invoked on column 0
  2012-07-30 19:52 org-fill-paragraph invoked on column 0 Michael Brand
@ 2012-07-30 21:49 ` Nicolas Goaziou
  2012-07-31 15:35   ` Michael Brand
  0 siblings, 1 reply; 11+ messages in thread
From: Nicolas Goaziou @ 2012-07-30 21:49 UTC (permalink / raw)
  To: Michael Brand; +Cc: Org Mode

Hello,

Michael Brand <michael.ch.brand@gmail.com> writes:

> I could move up and down through the lines and fill list items with
> M-q also when staying on column 0. Now I have to move right at least
> until the item body starts which is less comfortable for me. Is there
> a reason why this should not be possible any more between column 0 and
> the item body start?

Yes. It's all about document's structure. First paragraph starts after
bullet. Before, it's the item. Since you want to fill the first
paragraph, you have to move into it.

You can use navigation functions, move to the end of line, which is
quicker, or to the beginning of the next line, even at column 0.


Regards,

-- 
Nicolas Goaziou

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

* Re: org-fill-paragraph invoked on column 0
  2012-07-30 21:49 ` Nicolas Goaziou
@ 2012-07-31 15:35   ` Michael Brand
  2012-07-31 18:59     ` Nicolas Goaziou
  0 siblings, 1 reply; 11+ messages in thread
From: Michael Brand @ 2012-07-31 15:35 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Org Mode

Hi Nicolas

On Mon, Jul 30, 2012 at 11:49 PM, Nicolas Goaziou <n.goaziou@gmail.com> wrote:
> Yes. It's all about document's structure. First paragraph starts after
> bullet. Before, it's the item. Since you want to fill the first
> paragraph, you have to move into it.

Thank you for the explanations. I appreciate your improvements in
correctness of parsing and interpreting the Org structure.

Oh, and only now I see that, as your improvements exclude the item
bullet from filling, C-c and M-q (org-fill-paragraph) now leave the
manual alignment of the description in description lists untouched.
This is nice, it helps me as shown in my new post here:

"alignment of description list in Org and export old and new"
http://thread.gmane.org/gmane.emacs.orgmode/56631/focus=58222

> You can use navigation functions, move to the end of line, which is
> quicker, or to the beginning of the next line, even at column 0.

Because I need to fill list items so often and when I am on column 0
of the bullet line, I start to override M-q at least until maybe the
community decides that this old behaviour of M-q should be restored:

#+BEGIN_SRC emacs-lisp
  (add-hook 'org-mode-hook 'my-org-bind-M-q)
  (defun my-org-bind-M-q ()
    (define-key org-mode-map "\M-q" 'my-org-fill-paragraph))
  (defun my-org-fill-paragraph ()
    (interactive)
    (if (and (org-in-item-p) (not mark-active))
        (save-excursion
          ;; must deal also with:
          ;;   - cmd --log-level=wrn -o DST SRC ::
          ;;                               description
          ;;        for long term
          ;; or:
          ;;   - cmd --log-level=wrn -o DST SRC
          ;;                            :: description
          ;;        for long term
          (org-end-of-item)
          (backward-char)
          (org-fill-paragraph))
      (org-fill-paragraph)))
#+END_SRC

Michael

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

* Re: org-fill-paragraph invoked on column 0
  2012-07-31 15:35   ` Michael Brand
@ 2012-07-31 18:59     ` Nicolas Goaziou
  2012-07-31 19:39       ` Michael Brand
  0 siblings, 1 reply; 11+ messages in thread
From: Nicolas Goaziou @ 2012-07-31 18:59 UTC (permalink / raw)
  To: Michael Brand; +Cc: Org Mode

Hello,

Michael Brand <michael.ch.brand@gmail.com> writes:

> Because I need to fill list items so often and when I am on column 0
> of the bullet line, I start to override M-q at least until maybe the
> community decides that this old behaviour of M-q should be restored:

It will probably be a common request, so I've pushed a convenience
patch: when point is at an item or a footnote definition, the function
will try to fill the first paragraph within.


Regards,

-- 
Nicolas Goaziou

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

* Re: org-fill-paragraph invoked on column 0
  2012-07-31 18:59     ` Nicolas Goaziou
@ 2012-07-31 19:39       ` Michael Brand
  2012-07-31 20:01         ` Michael Brand
  2012-07-31 22:15         ` Nicolas Goaziou
  0 siblings, 2 replies; 11+ messages in thread
From: Michael Brand @ 2012-07-31 19:39 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Org Mode

Hi Nicolas

On Tue, Jul 31, 2012 at 8:59 PM, Nicolas Goaziou <n.goaziou@gmail.com> wrote:
> It will probably be a common request, so I've pushed a convenience
> patch: when point is at an item or a footnote definition, the function
> will try to fill the first paragraph within.

Thanks. It works except for description list. My requirement is that
it works even with unusually placed "::" which work already when point
is within the item body:

  - cmd --log-level=wrn -o DST SRC ::
                              description
       for long term
  - cmd --log-level=wrn -o DST SRC
                           :: description
       for long term

Michael

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

* Re: org-fill-paragraph invoked on column 0
  2012-07-31 19:39       ` Michael Brand
@ 2012-07-31 20:01         ` Michael Brand
  2012-07-31 22:42           ` Nicolas Goaziou
  2012-07-31 22:15         ` Nicolas Goaziou
  1 sibling, 1 reply; 11+ messages in thread
From: Michael Brand @ 2012-07-31 20:01 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Org Mode

Hi Nicolas

On Tue, Jul 31, 2012 at 9:39 PM, Michael Brand
<michael.ch.brand@gmail.com> wrote:
> Thanks. It works except for description list. My requirement is that
> it works even with unusually placed "::" which work already when point
> is within the item body:

In my override my-org-fill-paragraph, improved over the one in an
earlier post I use

#+BEGIN_SRC emacs-lisp
  (save-excursion
    (org-end-of-item)
    (re-search-backward "[^[:space:]]")
    ;; [...]
#+END_SRC

to achieve this. May I suggest to use the same instead of the current

#+BEGIN_SRC emacs-lisp
  (save-excursion
    (end-of-line)
    ;; [...]
#+END_SRC

in org-fill-paragraph?

Michael

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

* Re: org-fill-paragraph invoked on column 0
  2012-07-31 19:39       ` Michael Brand
  2012-07-31 20:01         ` Michael Brand
@ 2012-07-31 22:15         ` Nicolas Goaziou
  2012-08-01 14:07           ` Michael Brand
  1 sibling, 1 reply; 11+ messages in thread
From: Nicolas Goaziou @ 2012-07-31 22:15 UTC (permalink / raw)
  To: Michael Brand; +Cc: Org Mode

Hello,

Michael Brand <michael.ch.brand@gmail.com> writes:

> Thanks. It works except for description list. My requirement is that
> it works even with unusually placed "::" which work already when point
> is within the item body:
>
>   - cmd --log-level=wrn -o DST SRC ::
>                               description
>        for long term

This is a very special case. Trying to handle this would change the
simple convenience patch into larger machinery. I don't think it's worth
it since all it costs is a C-n before the M-q.


>   - cmd --log-level=wrn -o DST SRC
>                            :: description
>        for long term

This isn't even valid syntax.  At the moment, Org assumes the double
colons are on the same line as the bullet.


Regards,

-- 
Nicolas Goaziou

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

* Re: org-fill-paragraph invoked on column 0
  2012-07-31 20:01         ` Michael Brand
@ 2012-07-31 22:42           ` Nicolas Goaziou
  2012-08-01 14:05             ` Michael Brand
  0 siblings, 1 reply; 11+ messages in thread
From: Nicolas Goaziou @ 2012-07-31 22:42 UTC (permalink / raw)
  To: Michael Brand; +Cc: Org Mode

Hello,

Michael Brand <michael.ch.brand@gmail.com> writes:

> In my override my-org-fill-paragraph, improved over the one in an
> earlier post I use
>
> #+BEGIN_SRC emacs-lisp
>   (save-excursion
>     (org-end-of-item)
>     (re-search-backward "[^[:space:]]")
>     ;; [...]
> #+END_SRC
>
> to achieve this.

It doesn't work as you expect. Try it with the following example:

--8<---------------cut here---------------start------------->8---
- line 1
  line 2

  line 3
  line 4
--8<---------------cut here---------------end--------------->8---


Regards,

-- 
Nicolas Goaziou

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

* Re: org-fill-paragraph invoked on column 0
  2012-07-31 22:42           ` Nicolas Goaziou
@ 2012-08-01 14:05             ` Michael Brand
  0 siblings, 0 replies; 11+ messages in thread
From: Michael Brand @ 2012-08-01 14:05 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Org Mode

Hi Nicolas

On Wed, Aug 1, 2012 at 12:42 AM, Nicolas Goaziou <n.goaziou@gmail.com> wrote:

> It doesn't work as you expect. Try it with the following example:
>
> --8<---------------cut here---------------start------------->8---
> - line 1
>   line 2
>
>   line 3
>   line 4
> --8<---------------cut here---------------end--------------->8---

Indeed, I forgot about the existence of multi-paragraph items and that
it means of course that one single M-q does not always act on the
whole item body.

Michael

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

* Re: org-fill-paragraph invoked on column 0
  2012-08-01 14:07           ` Michael Brand
@ 2012-08-01 14:05             ` Nicolas Goaziou
  0 siblings, 0 replies; 11+ messages in thread
From: Nicolas Goaziou @ 2012-08-01 14:05 UTC (permalink / raw)
  To: Michael Brand; +Cc: Org Mode

Hello,

Michael Brand <michael.ch.brand@gmail.com> writes:

> Yes, together with multi-paragraph items now I see that this would be
> quite more complicated than I first thought. Also e. g.
> forward-paragraph (stumbles over "- A\n- B\n\n") or
> org-element-forward (different purpose) can not help here.

Note that there is `org-element-down' to enter container elements.


Regards,

-- 
Nicolas Goaziou

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

* Re: org-fill-paragraph invoked on column 0
  2012-07-31 22:15         ` Nicolas Goaziou
@ 2012-08-01 14:07           ` Michael Brand
  2012-08-01 14:05             ` Nicolas Goaziou
  0 siblings, 1 reply; 11+ messages in thread
From: Michael Brand @ 2012-08-01 14:07 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Org Mode

Hi Nicolas

On Wed, Aug 1, 2012 at 12:15 AM, Nicolas Goaziou <n.goaziou@gmail.com> wrote:

>>   - cmd --log-level=wrn -o DST SRC ::
>>                               description
>>        for long term
>
> This is a very special case. Trying to handle this would change the
> simple convenience patch into larger machinery. I don't think it's worth
> it since all it costs is a C-n before the M-q.

Yes, together with multi-paragraph items now I see that this would be
quite more complicated than I first thought. Also e. g.
forward-paragraph (stumbles over "- A\n- B\n\n") or
org-element-forward (different purpose) can not help here.

Michael

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

end of thread, other threads:[~2012-08-01 14:09 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-30 19:52 org-fill-paragraph invoked on column 0 Michael Brand
2012-07-30 21:49 ` Nicolas Goaziou
2012-07-31 15:35   ` Michael Brand
2012-07-31 18:59     ` Nicolas Goaziou
2012-07-31 19:39       ` Michael Brand
2012-07-31 20:01         ` Michael Brand
2012-07-31 22:42           ` Nicolas Goaziou
2012-08-01 14:05             ` Michael Brand
2012-07-31 22:15         ` Nicolas Goaziou
2012-08-01 14:07           ` Michael Brand
2012-08-01 14:05             ` 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).