Subject: Re: bug#78561: [PATCH] Add semantic linefeed support for paragraph filling

From: Juri Linkov <[email-masked]>
Date: Sun, 15 Jun 2025 19:28:44 +0300

> One option is setting a key binding, like this:
>
>   (keymap-global-set "C-c q" #'fill-paragraph-semlf)
>
> Then you can invoke the command placing the cursor within a paragraph
> and using 'C-c q' (or 'M-x fill-paragraph-semlf').

Unfortunately, additional keybindings is too much baggage to bear:
more keys to remember and type, etc.

>> (setq-local fill-paragraph-function 'fill-paragraph-semlf)
>
> This works.  However, the behavior of the usual key binding 'M-q'
> depends on the major-mode that is enabled.  For instance, `org-mode'
> binds 'M-q' to `org-fill-paragraph' and won't invoke
> 'fill-paragraph-semlf.  But placing the cursor within a paragraph a
> invoking `fill-paragraph' works.  On the flip side, other modes
> (e.g. `outline-mode' or `texinfo-mode') don't do that and you can use
> 'M-q' to invoke `fill-paragraph' and, thus, `fill-paragraph-semlf'
> normally.

I tried to add to .dir-locals.el:

  ((org-mode . ((fill-paragraph-function . fill-paragraph-semlf))))

and it works nicely.  With one exception that it fails on the active region.

But we could add a new variable, e.g. 'fill-region-function'
that will be possible to customize to 'fill-region-as-paragraph-semlf'.

Although it's strange that 'fill-region-as-paragraph-semlf'
doesn't keep empty lines between paragraphs like 'fill-region' does.