* Necessity of `org-fill-paragraph'
@ 2020-06-04 12:04 Dominik Schrempf
2020-06-04 12:37 ` Nicolas Goaziou
0 siblings, 1 reply; 4+ messages in thread
From: Dominik Schrempf @ 2020-06-04 12:04 UTC (permalink / raw)
To: emacs-orgmode@gnu.org
Hello,
I am using a global keybinding for =M-q=, so that I can fill and unfill
paragraphs with one key stroke (unfill.el):
: (global-set-key (kbd "s-q") 'unfill-toggle)
For a long time, I thought that =fill-paragraph= was broken in Org mode, because
it doesn't work well on code blocks, on lists, and on many other things [1].
Just now, I realized that Org mode uses a specialized version of
`fill-paragraph`, called `org-fill-paragraph`.
Hence, the aforementioned global key binding breaks behavior in Org mode,
although the function =unfill-toggle= is just a wrapper around =fill-paragraph=.
Is it necessary to have the specialized function =org-fill-paragraph=? Is it
possible to use the canonical =fill-paragraph=?
Thanks,
Dominik
[1] https://github.com/syl20bnr/spacemacs/issues/13384
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Necessity of `org-fill-paragraph'
2020-06-04 12:04 Necessity of `org-fill-paragraph' Dominik Schrempf
@ 2020-06-04 12:37 ` Nicolas Goaziou
2020-06-04 12:49 ` Dominik Schrempf
0 siblings, 1 reply; 4+ messages in thread
From: Nicolas Goaziou @ 2020-06-04 12:37 UTC (permalink / raw)
To: Dominik Schrempf; +Cc: emacs-orgmode@gnu.org
Hello,
Dominik Schrempf <dominik.schrempf@gmail.com> writes:
> I am using a global keybinding for =M-q=, so that I can fill and unfill
> paragraphs with one key stroke (unfill.el):
>
> : (global-set-key (kbd "s-q") 'unfill-toggle)
>
> For a long time, I thought that =fill-paragraph= was broken in Org mode, because
> it doesn't work well on code blocks, on lists, and on many other things [1].
> Just now, I realized that Org mode uses a specialized version of
> `fill-paragraph`, called `org-fill-paragraph`.
>
> Hence, the aforementioned global key binding breaks behavior in Org mode,
> although the function =unfill-toggle= is just a wrapper around
> =fill-paragraph=.
You could detect if you're in an Org document beforehand.
`org-fill-paragraph' obeys to `fill-column'.
> Is it necessary to have the specialized function =org-fill-paragraph=? Is it
> possible to use the canonical =fill-paragraph=?
There is `fill-paragraph-function', but it only kicks when no region is
selected. Using it would break region filling. There is also
`fill-forward-paragraph-function', but I think it is too limited.
In a nutshell, I didn't find any way to fill correctly Org documents
using `fill-paragraph' mechanism. So I wrote the current implementation
of `org-fill-paragraph', which is a wrapper around `org-fill-element'.
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Necessity of `org-fill-paragraph'
2020-06-04 12:37 ` Nicolas Goaziou
@ 2020-06-04 12:49 ` Dominik Schrempf
2020-06-04 12:53 ` Eric S Fraga
0 siblings, 1 reply; 4+ messages in thread
From: Dominik Schrempf @ 2020-06-04 12:49 UTC (permalink / raw)
To: Nicolas Goaziou; +Cc: emacs-orgmode@gnu.org
Dear Nicolas!
Thank you for your fast reply! I now use a custom =org-unfill-toggle= which does
the same as =unfill-toggle= but uses =org-fill-paragraph=. It just took me a
while to see where the problem lies! For cases like these, it would be
advantageous if major modes could redefine certain functions. Like
=fill-paragraph= in this case. Instead, they usually (have to?) rebind the
keys...
Kind regards,
Dominik
Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:
> Hello,
>
> Dominik Schrempf <dominik.schrempf@gmail.com> writes:
>
>> I am using a global keybinding for =M-q=, so that I can fill and unfill
>> paragraphs with one key stroke (unfill.el):
>>
>> : (global-set-key (kbd "s-q") 'unfill-toggle)
>>
>> For a long time, I thought that =fill-paragraph= was broken in Org mode, because
>> it doesn't work well on code blocks, on lists, and on many other things [1].
>> Just now, I realized that Org mode uses a specialized version of
>> `fill-paragraph`, called `org-fill-paragraph`.
>>
>> Hence, the aforementioned global key binding breaks behavior in Org mode,
>> although the function =unfill-toggle= is just a wrapper around
>> =fill-paragraph=.
>
> You could detect if you're in an Org document beforehand.
> `org-fill-paragraph' obeys to `fill-column'.
>
>> Is it necessary to have the specialized function =org-fill-paragraph=? Is it
>> possible to use the canonical =fill-paragraph=?
>
> There is `fill-paragraph-function', but it only kicks when no region is
> selected. Using it would break region filling. There is also
> `fill-forward-paragraph-function', but I think it is too limited.
>
> In a nutshell, I didn't find any way to fill correctly Org documents
> using `fill-paragraph' mechanism. So I wrote the current implementation
> of `org-fill-paragraph', which is a wrapper around `org-fill-element'.
>
> Regards,
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Necessity of `org-fill-paragraph'
2020-06-04 12:49 ` Dominik Schrempf
@ 2020-06-04 12:53 ` Eric S Fraga
0 siblings, 0 replies; 4+ messages in thread
From: Eric S Fraga @ 2020-06-04 12:53 UTC (permalink / raw)
To: Dominik Schrempf; +Cc: emacs-orgmode@gnu.org, Nicolas Goaziou
On Thursday, 4 Jun 2020 at 14:49, Dominik Schrempf wrote:
> For cases like these, it would be advantageous if major modes could
> redefine certain functions.
fill-paragraph will check fill-paragraph-function and, if that this
defined, it will be used instead of the default behaviour.
--
: Eric S Fraga via Emacs 28.0.50, Org release_9.3.6-640-g9bc0cc
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-06-04 12:54 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-06-04 12:04 Necessity of `org-fill-paragraph' Dominik Schrempf
2020-06-04 12:37 ` Nicolas Goaziou
2020-06-04 12:49 ` Dominik Schrempf
2020-06-04 12:53 ` Eric S Fraga
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).