# HG changeset patch # User Juri Linkov # Date 1191708910 0 # Node ID 8058943a15e4e924210edfc90693f8973ab2716d # Parent 6d4dbcc19e804777e8fda54d077fcd3e31f2d5bc (fill-paragraph-or-region): New function. diff -r 6d4dbcc19e80 -r 8058943a15e4 lisp/textmodes/fill.el --- a/lisp/textmodes/fill.el Sat Oct 06 14:36:09 2007 +0000 +++ b/lisp/textmodes/fill.el Sat Oct 06 22:15:10 2007 +0000 @@ -1007,6 +1007,18 @@ (goto-char end)))) fill-pfx)) +(defun fill-paragraph-or-region (arg) + "Fill the active region or current paragraph. +In Transient Mark mode, when the mark is active, it calls `fill-region' +on the active region. Otherwise, it calls `fill-paragraph'." + (interactive (progn + (barf-if-buffer-read-only) + (list (if current-prefix-arg 'full)))) + (if (and transient-mark-mode mark-active + (not (eq (region-beginning) (region-end)))) + (fill-region (region-beginning) (region-end) arg) + (fill-paragraph arg))) + (defcustom default-justification 'left "*Method of justifying text not otherwise specified.