diff options
| author | Sean Whitton | 2025-06-27 14:14:36 +0100 |
|---|---|---|
| committer | Sean Whitton | 2025-06-27 14:14:36 +0100 |
| commit | 0c0ac8d48a154779bc349da9fae2a2cf0230ff5d (patch) | |
| tree | c1ceb641d532a26acd344902ea7b566ea712be27 | |
| parent | 772099bc9b8043d46154992e1f06d7b4aa9ceccd (diff) | |
| download | emacs-0c0ac8d48a154779bc349da9fae2a2cf0230ff5d.tar.gz emacs-0c0ac8d48a154779bc349da9fae2a2cf0230ff5d.zip | |
'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.
| -rw-r--r-- | doc/emacs/text.texi | 5 | ||||
| -rw-r--r-- | etc/NEWS | 5 | ||||
| -rw-r--r-- | lisp/textmodes/fill.el | 23 |
3 files changed, 21 insertions, 12 deletions
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. | |||
| 699 | To specify a fill prefix for the current buffer, move to a line that | 699 | To specify a fill prefix for the current buffer, move to a line that |
| 700 | starts with the desired prefix, put point at the end of the prefix, | 700 | starts with the desired prefix, put point at the end of the prefix, |
| 701 | and type @w{@kbd{C-x .}}@: (@code{set-fill-prefix}). (That's a period | 701 | and type @w{@kbd{C-x .}}@: (@code{set-fill-prefix}). (That's a period |
| 702 | after the @kbd{C-x}.) To turn off the fill prefix, specify an empty | 702 | after the @kbd{C-x}.) To turn off the fill prefix, either type |
| 703 | prefix: type @w{@kbd{C-x .}}@: with point at the beginning of a line. | 703 | @w{@kbd{C-u C-x .}}@: or specify an empty prefix: type @w{@kbd{C-x .}}@: |
| 704 | with point at the beginning of a line. | ||
| 704 | 705 | ||
| 705 | When a fill prefix is in effect, the fill commands remove the fill | 706 | When a fill prefix is in effect, the fill commands remove the fill |
| 706 | prefix from each line of the paragraph before filling, and insert it | 707 | prefix from each line of the paragraph before filling, and insert it |
| @@ -619,6 +619,11 @@ sentence. The new command 'fill-region-as-paragraph-semlf' fills a | |||
| 619 | region of text using semantic linefeeds as if the region were a single | 619 | region of text using semantic linefeeds as if the region were a single |
| 620 | paragraph. | 620 | paragraph. |
| 621 | 621 | ||
| 622 | +++ | ||
| 623 | ** 'C-u C-x .' clears the fill prefix. | ||
| 624 | You can now use 'C-u C-x .' to clear the fill prefix, similarly to how | ||
| 625 | you could already use 'C-u C-x C-n' to clear the goal column. | ||
| 626 | |||
| 622 | 627 | ||
| 623 | * Changes in Specialized Modes and Packages in Emacs 31.1 | 628 | * Changes in Specialized Modes and Packages in Emacs 31.1 |
| 624 | 629 | ||
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. | |||
| 78 | See the documentation of `kinsoku' for more information." | 78 | See the documentation of `kinsoku' for more information." |
| 79 | :type 'boolean) | 79 | :type 'boolean) |
| 80 | 80 | ||
| 81 | (defun set-fill-prefix () | 81 | (defun set-fill-prefix (&optional arg) |
| 82 | "Set the fill prefix to the current line up to point. | 82 | "Set the fill prefix to the current line up to point. |
| 83 | Filling expects lines to start with the fill prefix and | 83 | Filling expects lines to start with the fill prefix and |
| 84 | reinserts the fill prefix in each resulting line." | 84 | reinserts the fill prefix in each resulting line. |
| 85 | (interactive) | 85 | With a prefix argument, cancel the fill prefix." |
| 86 | (let ((left-margin-pos (save-excursion (move-to-left-margin) (point)))) | 86 | (interactive "P") |
| 87 | (if (> (point) left-margin-pos) | 87 | (if arg |
| 88 | (progn | 88 | (setq fill-prefix nil) |
| 89 | (setq fill-prefix (buffer-substring left-margin-pos (point))) | 89 | (let ((left-margin-pos (save-excursion (move-to-left-margin) (point)))) |
| 90 | (if (equal fill-prefix "") | 90 | (if (> (point) left-margin-pos) |
| 91 | (progn | ||
| 92 | (setq fill-prefix (buffer-substring left-margin-pos (point))) | ||
| 93 | (when (equal fill-prefix "") | ||
| 91 | (setq fill-prefix nil))) | 94 | (setq fill-prefix nil))) |
| 92 | (setq fill-prefix nil))) | 95 | (setq fill-prefix nil)))) |
| 93 | (if fill-prefix | 96 | (if fill-prefix |
| 94 | (message "fill-prefix: \"%s\"" fill-prefix) | 97 | (message "fill-prefix: \"%s\"" fill-prefix) |
| 95 | (message "fill-prefix canceled"))) | 98 | (message "fill-prefix cancelled"))) |
| 96 | 99 | ||
| 97 | (defcustom adaptive-fill-mode t | 100 | (defcustom adaptive-fill-mode t |
| 98 | "Non-nil means determine a paragraph's fill prefix from its text." | 101 | "Non-nil means determine a paragraph's fill prefix from its text." |