]> git.eshelyaron.com Git - emacs.git/commitdiff
(fill-paragraph-or-region): New function.
authorJuri Linkov <juri@jurta.org>
Sat, 6 Oct 2007 22:15:10 +0000 (22:15 +0000)
committerJuri Linkov <juri@jurta.org>
Sat, 6 Oct 2007 22:15:10 +0000 (22:15 +0000)
lisp/textmodes/fill.el

index 88a4286aad2ae1d45e28c5771cf5ea787d5c777c..2671680542a4a3d356ab087f878dce49cd9cf93a 100644 (file)
@@ -1007,6 +1007,18 @@ space does not end a sentence, so don't break a line there."
          (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)))
+
 \f
 (defcustom default-justification 'left
   "*Method of justifying text not otherwise specified.