changeset 85069:8058943a15e4

(fill-paragraph-or-region): New function.
author Juri Linkov <juri@jurta.org>
date Sat, 06 Oct 2007 22:15:10 +0000
parents 6d4dbcc19e80
children 628c4c3a906d
files lisp/textmodes/fill.el
diffstat 1 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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.