'C-u C-x .' clears the fill prefix

* lisp/textmodes/fill.el (set-fill-prefix): When called
interactively with a prefix argument, clear the fill prefix,
just like how 'C-u C-x C-n' clears the goal column.
* doc/emacs/text.texi (Fill Prefix):
* etc/NEWS: Document the change.
This commit is contained in:
Sean Whitton 2025-06-27 14:14:36 +01:00
parent 772099bc9b
commit 0c0ac8d48a
3 changed files with 21 additions and 12 deletions

View file

@ -699,8 +699,9 @@ a new paragraph.
To specify a fill prefix for the current buffer, move to a line that
starts with the desired prefix, put point at the end of the prefix,
and type @w{@kbd{C-x .}}@: (@code{set-fill-prefix}). (That's a period
after the @kbd{C-x}.) To turn off the fill prefix, specify an empty
prefix: type @w{@kbd{C-x .}}@: with point at the beginning of a line.
after the @kbd{C-x}.) To turn off the fill prefix, either type
@w{@kbd{C-u C-x .}}@: or specify an empty prefix: type @w{@kbd{C-x .}}@:
with point at the beginning of a line.
When a fill prefix is in effect, the fill commands remove the fill
prefix from each line of the paragraph before filling, and insert it

View file

@ -619,6 +619,11 @@ sentence. The new command 'fill-region-as-paragraph-semlf' fills a
region of text using semantic linefeeds as if the region were a single
paragraph.
+++
** 'C-u C-x .' clears the fill prefix.
You can now use 'C-u C-x .' to clear the fill prefix, similarly to how
you could already use 'C-u C-x C-n' to clear the goal column.
* Changes in Specialized Modes and Packages in Emacs 31.1

View file

@ -78,21 +78,24 @@ placed at the beginning or end of a line by filling.
See the documentation of `kinsoku' for more information."
:type 'boolean)
(defun set-fill-prefix ()
(defun set-fill-prefix (&optional arg)
"Set the fill prefix to the current line up to point.
Filling expects lines to start with the fill prefix and
reinserts the fill prefix in each resulting line."
(interactive)
(let ((left-margin-pos (save-excursion (move-to-left-margin) (point))))
(if (> (point) left-margin-pos)
(progn
(setq fill-prefix (buffer-substring left-margin-pos (point)))
(if (equal fill-prefix "")
reinserts the fill prefix in each resulting line.
With a prefix argument, cancel the fill prefix."
(interactive "P")
(if arg
(setq fill-prefix nil)
(let ((left-margin-pos (save-excursion (move-to-left-margin) (point))))
(if (> (point) left-margin-pos)
(progn
(setq fill-prefix (buffer-substring left-margin-pos (point)))
(when (equal fill-prefix "")
(setq fill-prefix nil)))
(setq fill-prefix nil)))
(setq fill-prefix nil))))
(if fill-prefix
(message "fill-prefix: \"%s\"" fill-prefix)
(message "fill-prefix canceled")))
(message "fill-prefix cancelled")))
(defcustom adaptive-fill-mode t
"Non-nil means determine a paragraph's fill prefix from its text."