emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nicolas Goaziou <mail@nicolasgoaziou.fr>
To: Dominik Schrempf <dominik.schrempf@gmail.com>
Cc: "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Subject: Re: Necessity of `org-fill-paragraph'
Date: Thu, 04 Jun 2020 14:37:53 +0200	[thread overview]
Message-ID: <87wo4nropq.fsf@nicolasgoaziou.fr> (raw)
In-Reply-To: <87a71jyr3m.fsf@gmail.com> (Dominik Schrempf's message of "Thu, 04 Jun 2020 14:04:29 +0200")

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


  reply	other threads:[~2020-06-04 12:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-04 12:04 Dominik Schrempf
2020-06-04 12:37 ` Nicolas Goaziou [this message]
2020-06-04 12:49   ` Dominik Schrempf
2020-06-04 12:53     ` Eric S Fraga

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wo4nropq.fsf@nicolasgoaziou.fr \
    --to=mail@nicolasgoaziou.fr \
    --cc=dominik.schrempf@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --subject='Re: Necessity of `org-fill-paragraph'\''' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Code repositories for project(s) associated with this 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).