Commit 89cd98f3 authored by Richard M. Stallman's avatar Richard M. Stallman

(fill-paragraph): Don't actually change point before

calling fill-region-as-paragraph.
(fill-region-as-paragraph): Save point on undo list at start.
parent 58ff020d
...@@ -57,6 +57,9 @@ for the paragraph.") ...@@ -57,6 +57,9 @@ for the paragraph.")
Prefix arg means justify too. Prefix arg means justify too.
From program, pass args FROM, TO and JUSTIFY-FLAG." From program, pass args FROM, TO and JUSTIFY-FLAG."
(interactive "r\nP") (interactive "r\nP")
;; Arrange for undoing the fill to restore point.
(if (and buffer-undo-list (not (eq buffer-undo-list t)))
(setq buffer-undo-list (cons (point) buffer-undo-list)))
;; Don't let Adaptive Fill mode alter the fill prefix permanently. ;; Don't let Adaptive Fill mode alter the fill prefix permanently.
(let ((fill-prefix fill-prefix)) (let ((fill-prefix fill-prefix))
;; Figure out how this paragraph is indented, if desired. ;; Figure out how this paragraph is indented, if desired.
...@@ -195,12 +198,14 @@ From program, pass args FROM, TO and JUSTIFY-FLAG." ...@@ -195,12 +198,14 @@ From program, pass args FROM, TO and JUSTIFY-FLAG."
(defun fill-paragraph (arg) (defun fill-paragraph (arg)
"Fill paragraph at or after point. Prefix arg means justify as well." "Fill paragraph at or after point. Prefix arg means justify as well."
(interactive "P") (interactive "P")
(save-excursion (let ((before (point)))
(forward-paragraph) (save-excursion
(or (bolp) (newline 1)) (forward-paragraph)
(let ((end (point))) (or (bolp) (newline 1))
(backward-paragraph) (let ((end (point))
(fill-region-as-paragraph (point) end arg)))) (beg (progn (backward-paragraph) (point))))
(goto-char before)
(fill-region-as-paragraph beg end arg)))))
(defun fill-region (from to &optional justify-flag) (defun fill-region (from to &optional justify-flag)
"Fill each of the paragraphs in the region. "Fill each of the paragraphs in the region.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment