diff --git a/doc/emacs/text.texi b/doc/emacs/text.texi index 5635171f5cf..51c6c2c5dc7 100644 --- a/doc/emacs/text.texi +++ b/doc/emacs/text.texi @@ -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 diff --git a/etc/NEWS b/etc/NEWS index 32f08d63c68..ea1a4ebeffa 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -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 diff --git a/lisp/textmodes/fill.el b/lisp/textmodes/fill.el index 386a88bda3a..1583ba4df05 100644 --- a/lisp/textmodes/fill.el +++ b/lisp/textmodes/fill.el @@ -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."