help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: unfill/defill


From: Gareth Rees
Subject: Re: unfill/defill
Date: 31 Mar 2003 05:11:19 -0800

chrisl_ak@hotmail.com wrote:
> I sometimes need to take a few paragraphs (2-20) from a text file
> created in Emacs using auto-fill and put them into another
> application. All paragraphs are separated by a blank line. What is the
> simplest way to "unfill" or "defill" these paragraphs so that each
> paragraph is one long line? Ideally I could highlight the whole region
> with the paragraphs I need and unfill them all at once, but retain a
> blank line between each one...

You can "unfill" all the paragraphs in the region by setting
`fill-column' to a large number and executing `fill-region', then
removing blank lines between paragraphs.  For example

  (defun unfill-region (start end)
     (interactive "r")
     (save-excursion
       (save-restriction
         (let ((fill-column (point-max)))
           (fill-region (point-min) (point-max) nil t)
           (goto-char (point-min))
           (while (search-forward "\n\n" nil t)
             (replace-match "\n"))))))

(It seems to me that on operating systems that have "rich text"
clipboard formats, such as Windows and Macintosh, you ought to be able
to do this by turning on Enriched Mode and then just copying and
pasting.  But Emacs 21 doesn't provide this.)

-- 
Gareth Rees


reply via email to

[Prev in Thread] Current Thread [Next in Thread]