[prog] replacement strings

Eeva Järvinen ejarvinen at gmail.com
Tue May 25 11:05:08 UTC 2010

2010/5/24 Miriam English <mim at miriam-english.org>

> At the risk of looking stupid again...
> I've been spending hours trying to find something that does the same thing
> as TextPad's join command. (I really want to get rid of my need for wine.)
> It joins highlighted text into single lines, keeping paragraphs distinct.
> The closest I've been able to find is the fmt command (part of the Gnu
> coreutils, and should be in most linuxes). Unfortunately that has an upper
> limit of 2,500 characters in a paragraph, which is unrealistic when trying
> to reformat some texts, especially old ones where most of a page might be a
> single paragraph.
> I have a feeling I might need to write a program to do the job, but that
> wouldn't be interactive so would have to make automated decisions on whether
> something should be joined or not based on line length (to leave bits of
> verse alone). [sigh] I've been spoiled by TextPad and its easy ability to
> select a range then join every line within the selection while retaining
> paragraphs.
This nice bit of elisp does the job of joining one paragraph into a single

(defun unfill-paragraph () "Does the opposite of fill-paragraph"
(interactive) (let ((fill-column (point-max))) (fill-paragraph nil)))

I pilfered it from
just so that you know.

If you want to use it in emacs, paste the line into *scratch* buffer, go to
the end of that line, type C-x, C-e (that's control+x followed by control+e)
and you're good to test it.  Switch to a buffer that has text, go to a
paragraph you want to convert into a single line, type Esc, x (M-x in
emacs-ese), unfill-paragraph and press enter.

If you like it, paste the snippet of code into your .emacs and perhaps
define a key for running it.


More information about the Programming mailing list