I would like to fill justify all paragraphs in the current buffer if no region is selected. I wrote the the following function which performs this job.
Is there a better way to write this function? Is there a build-in function which performs this job?
(defun my-fill-buffer ()
(interactive)
(if (not (region-active-p))
(save-excursion
(mark-whole-buffer)
(call-interactively 'fill-region))))
C-x h <tab>
. So I don't need a special command for that.C-x h <tab>
andC-x h M-x fill-region
is different. What I need is the latter.C-x h M-q
. (See doc offill-paragraph
:The REGION argument is non-nil if called interactively; in that case, if Transient Mark mode is enabled and the mark is active, call ‘fill-region’ to fill each of the paragraphs in the active region, instead of just filling the current paragraph.
)C-x h
followed byC-u M-q
will justify each paragraph in the buffer.