mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-03-12 09:51:05 -07:00
; Move unfill-paragraph to fill.el. Document it in (elisp)Filling.
This commit is contained in:
parent
a54e10baeb
commit
39abb7ec8f
5 changed files with 82 additions and 80 deletions
|
|
@ -115,28 +115,6 @@ With a prefix argument, join the current line to the following line.
|
|||
If the region is active, and no prefix argument is given, join all
|
||||
lines in the region instead.
|
||||
|
||||
@item M-x unfill-paragraph
|
||||
@findex unfill-paragraph
|
||||
Merge the lines of the current paragraph. This is like starting on the
|
||||
last line of the paragraph and repeatedly typing @kbd{M-^} until all the
|
||||
lines are joined. It can also be understood as the inverse of @kbd{M-q}
|
||||
(@code{fill-paragraph}).
|
||||
|
||||
With a numeric prefix argument, apply the operation to that many
|
||||
paragraphs. For example, with a numeric prefix argument of 2, join all
|
||||
the lines in this paragraph and all the lines in the next paragraph, but
|
||||
preserve the separation of the two paragraphs.
|
||||
|
||||
With no prefix argument and an active region, apply the operation to all
|
||||
paragraphs in that region. If the region begins or ends within a
|
||||
paragraph, treat the partial paragraph that's within the region as the
|
||||
whole paragraph whose lines are to be joined.
|
||||
|
||||
With no prefix argument and an active region, this command is roughly
|
||||
the same as @kbd{M-^} with that same active region, except that this
|
||||
command only joins lines within paragraphs, preserving the paragraphs
|
||||
themselves.
|
||||
|
||||
@item C-M-\
|
||||
@kindex C-M-\
|
||||
@findex indent-region
|
||||
|
|
|
|||
|
|
@ -573,9 +573,11 @@ Fill current paragraph (@code{fill-paragraph}).
|
|||
@item C-x f
|
||||
Set the fill column (@code{set-fill-column}).
|
||||
@item M-x fill-region
|
||||
Fill each paragraph in the region (@code{fill-region}).
|
||||
Fill each paragraph in the region.
|
||||
@item M-x fill-region-as-paragraph
|
||||
Fill the region, considering it as one paragraph.
|
||||
@item M-x unfill-paragraph
|
||||
Unfill current paragraph.
|
||||
@item M-x center-line
|
||||
Center a line.
|
||||
@end table
|
||||
|
|
@ -633,6 +635,18 @@ particular, using variable-pitch fonts will cause the
|
|||
@code{fill-column} occupy different horizontal positions on display in
|
||||
different lines.
|
||||
|
||||
@cindex unfilling
|
||||
@findex unfill-paragraph
|
||||
The command @kbd{M-x unfill-paragraph} is the inverse of @kbd{M-q}.
|
||||
It joins up the lines of the current paragraph. Using this command is
|
||||
like starting on the last line of the paragraph and repeatedly typing
|
||||
@kbd{M-^} (@pxref{Indentation Commands}) until all the lines are joined.
|
||||
With a numeric prefix argument, apply the operation to that many
|
||||
paragraphs. For example, with a numeric prefix argument of 2, join all
|
||||
the lines in this paragraph and all the lines in the next paragraph, but
|
||||
preserve the separation of the two paragraphs. When there is no prefix
|
||||
argument, it acts on an active region just like @kbd{M-q}.
|
||||
|
||||
@cindex centering
|
||||
@findex center-line
|
||||
The command @kbd{M-x center-line} centers the current line
|
||||
|
|
|
|||
|
|
@ -1651,6 +1651,16 @@ current paragraph. When this command is called interactively,
|
|||
@var{region} is @code{t}.
|
||||
@end deffn
|
||||
|
||||
@deffn Command unfill-paragraph arg &optional beg end
|
||||
This command is the inverse of the previous one: it joins up the lines
|
||||
of the current paragraph. With a numeric prefix argument @var{arg}, it
|
||||
applies the operation to that many paragraphs. With no prefix argument
|
||||
and an active region, unfill each paragraph in that region. When called
|
||||
from Lisp with @var{arg} @code{nil} and @var{beg} and @var{end}
|
||||
non-@code{nil}, unfill paragraphs in the region delimited by @var{beg}
|
||||
and @var{end}.
|
||||
@end deffn
|
||||
|
||||
@deffn Command fill-region start end &optional justify nosqueeze to-eop
|
||||
This command fills each of the paragraphs in the region from @var{start}
|
||||
to @var{end}. It justifies as well if @var{justify} is
|
||||
|
|
|
|||
|
|
@ -807,63 +807,6 @@ ignored if prefix ARG is given.)"
|
|||
|
||||
(defalias 'join-line #'delete-indentation) ; easier to find
|
||||
|
||||
(defun unfill-paragraph (arg &optional beg end)
|
||||
"Join lines of this paragraph and fix up whitespace at joins.
|
||||
If there is a fill prefix, delete it from the beginning of lines before
|
||||
joining them.
|
||||
Interactively, if the region is active, join lines of each paragraph wholly
|
||||
contained within the region. This means that if the region begins or ends
|
||||
within a paragraph, treat the partial paragraph that's within the region as
|
||||
the whole paragraph whose lines are to be joined.
|
||||
A numeric prefix argument means join the lines of the following ARG
|
||||
paragraphs. In this case an active region is ignored.
|
||||
|
||||
With an active region and no prefix argument this is roughly the same as
|
||||
`delete-indentation' with that active region, except that this command
|
||||
only joins lines within paragraphs, preserving the paragraphs
|
||||
themselves.
|
||||
|
||||
When called from Lisp, ARG is the number of following paragraphs to join
|
||||
lines within, or if ARG is nil, optional arguments BEG and END non-nil
|
||||
means to join the lines of each paragraph in the region delimited by BEG
|
||||
and END."
|
||||
(interactive "P\nR")
|
||||
(let ((endm (make-marker)))
|
||||
(unwind-protect
|
||||
(cl-flet ((do-unfill ()
|
||||
(set-marker endm (point))
|
||||
(fill-forward-paragraph -1)
|
||||
;; Adjust BEG and ENDM by 1 because we want to
|
||||
;; preserve the newlines before and after the
|
||||
;; paragraph.
|
||||
(delete-indentation nil (1+ (point)) (1- endm))
|
||||
(goto-char endm)))
|
||||
(save-excursion
|
||||
(if (or arg (not beg) (not end))
|
||||
;; Do it ARG times or until we run out of paragraphs.
|
||||
(let ((n (prefix-numeric-value arg))
|
||||
(i 0))
|
||||
(while (and (< i n)
|
||||
(zerop (fill-forward-paragraph 1)))
|
||||
(do-unfill)
|
||||
(incf i)))
|
||||
;; Ensure there are newlines at beginning and end of
|
||||
;; region. This is how we handle a region starting or
|
||||
;; ending within a paragraph.
|
||||
(goto-char beg)
|
||||
(unless (or (bolp) (eolp))
|
||||
(open-line 1)
|
||||
(setq beg (point)))
|
||||
(goto-char end)
|
||||
(unless (or (bolp) (eolp))
|
||||
(newline 1)
|
||||
(setq end (point)))
|
||||
(with-restriction beg end
|
||||
(goto-char beg)
|
||||
(while (zerop (fill-forward-paragraph 1))
|
||||
(do-unfill))))))
|
||||
(set-marker endm nil))))
|
||||
|
||||
(defun delete-blank-lines ()
|
||||
"On blank line, delete all surrounding blank lines, leaving just one.
|
||||
On isolated blank line, delete that one.
|
||||
|
|
|
|||
|
|
@ -943,6 +943,63 @@ region, instead of just filling the current paragraph."
|
|||
(fill-region-as-paragraph beg end justify))))))
|
||||
fill-pfx))))
|
||||
|
||||
(defun unfill-paragraph (arg &optional beg end)
|
||||
"Join lines of this paragraph and fix up whitespace at joins.
|
||||
If there is a fill prefix, delete it from the beginning of lines before
|
||||
joining them.
|
||||
Interactively, if the region is active, join lines of each paragraph wholly
|
||||
contained within the region. This means that if the region begins or ends
|
||||
within a paragraph, treat the partial paragraph that's within the region as
|
||||
the whole paragraph whose lines are to be joined.
|
||||
A numeric prefix argument means join the lines of the following ARG
|
||||
paragraphs. In this case an active region is ignored.
|
||||
|
||||
With an active region and no prefix argument this is roughly the same as
|
||||
`delete-indentation' with that active region, except that this command
|
||||
only joins lines within paragraphs, preserving the paragraphs
|
||||
themselves.
|
||||
|
||||
When called from Lisp, ARG is the number of following paragraphs to join
|
||||
lines within, or if ARG is nil, optional arguments BEG and END non-nil
|
||||
means to join the lines of each paragraph in the region delimited by BEG
|
||||
and END."
|
||||
(interactive "P\nR")
|
||||
(let ((endm (make-marker)))
|
||||
(unwind-protect
|
||||
(cl-flet ((do-unfill ()
|
||||
(set-marker endm (point))
|
||||
(fill-forward-paragraph -1)
|
||||
;; Adjust BEG and ENDM by 1 because we want to
|
||||
;; preserve the newlines before and after the
|
||||
;; paragraph.
|
||||
(delete-indentation nil (1+ (point)) (1- endm))
|
||||
(goto-char endm)))
|
||||
(save-excursion
|
||||
(if (or arg (not beg) (not end))
|
||||
;; Do it ARG times or until we run out of paragraphs.
|
||||
(let ((n (prefix-numeric-value arg))
|
||||
(i 0))
|
||||
(while (and (< i n)
|
||||
(zerop (fill-forward-paragraph 1)))
|
||||
(do-unfill)
|
||||
(incf i)))
|
||||
;; Ensure there are newlines at beginning and end of
|
||||
;; region. This is how we handle a region starting or
|
||||
;; ending within a paragraph.
|
||||
(goto-char beg)
|
||||
(unless (or (bolp) (eolp))
|
||||
(open-line 1)
|
||||
(setq beg (point)))
|
||||
(goto-char end)
|
||||
(unless (or (bolp) (eolp))
|
||||
(newline 1)
|
||||
(setq end (point)))
|
||||
(with-restriction beg end
|
||||
(goto-char beg)
|
||||
(while (zerop (fill-forward-paragraph 1))
|
||||
(do-unfill))))))
|
||||
(set-marker endm nil))))
|
||||
|
||||
(declare-function comment-search-forward "newcomment" (limit &optional noerror))
|
||||
(declare-function comment-string-strip "newcomment" (str beforep afterp))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue