summaryrefslogtreecommitdiff
path: root/lisp/textmodes/fill.el
diff options
context:
space:
mode:
authorJuri Linkov <juri@jurta.org>2007-10-06 22:15:10 +0000
committerJuri Linkov <juri@jurta.org>2007-10-06 22:15:10 +0000
commite65f7c96771d19f89787faa815b9bde8f04a0b2f (patch)
treec1f9a0ed19e459fef70e3286f39f5fb564e0e0b7 /lisp/textmodes/fill.el
parentd6ba9c398efbd6bec64b897cc4ae3733bee30f98 (diff)
downloademacs-e65f7c96771d19f89787faa815b9bde8f04a0b2f.tar.gz
emacs-e65f7c96771d19f89787faa815b9bde8f04a0b2f.tar.bz2
emacs-e65f7c96771d19f89787faa815b9bde8f04a0b2f.zip
(fill-paragraph-or-region): New function.
Diffstat (limited to 'lisp/textmodes/fill.el')
-rw-r--r--lisp/textmodes/fill.el12
1 files changed, 12 insertions, 0 deletions
diff --git a/lisp/textmodes/fill.el b/lisp/textmodes/fill.el
index 88a4286aad2..2671680542a 100644
--- a/lisp/textmodes/fill.el
+++ b/lisp/textmodes/fill.el
@@ -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)))
+
(defcustom default-justification 'left
"*Method of justifying text not otherwise specified.