]> git.eshelyaron.com Git - emacs.git/commitdiff
'C-u C-x .' clears the fill prefix
authorSean Whitton <spwhitton@spwhitton.name>
Fri, 27 Jun 2025 13:14:36 +0000 (14:14 +0100)
committerEshel Yaron <me@eshelyaron.com>
Wed, 23 Jul 2025 20:06:04 +0000 (22:06 +0200)
* 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.

(cherry picked from commit 0c0ac8d48a154779bc349da9fae2a2cf0230ff5d)

doc/emacs/text.texi
lisp/textmodes/fill.el

index b0689fd0c9c3c3938c7454b07c499d505950482c..2950618f35fe9faed52c77f554240f374ffd0734 100644 (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
index 386a88bda3a83b8573a8eaecb50d57c621846d73..1583ba4df0516fe1246d3e730d4fd2c2d9dec7ac 100644 (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."