Unfilling a paragraph joins all the lines in a paragraph into a single line. It is the contrary of FillParagraph.
It works where a line ends with a newline character (”\n”) and paragraphs are separated by blank lines. To make a paragraph end in a single newline then use the function below:
;;; Stefan Monnier <foo at acm.org>. It is the opposite of fill-paragraph (defun unfill-paragraph (&optional region) "Takes a multi-line paragraph and makes it into a single line of text." (interactive (progn (barf-if-buffer-read-only) '(t))) (let ((fill-column (point-max)) ;; This would override `fill-column' if it's an integer. (emacs-lisp-docstring-fill-column t)) (fill-paragraph nil region)))
;; Handy key definition (define-key global-map "\M-Q" 'unfill-paragraph)
It is worth mentioning here that the key sequence ESC 9 9 9 9 9 9 9 9 ^X f sets fill-column to a very large number. With that, the key sequence M-q , or M-x fill-paragraph, unfills paragraphs. (That is eight digit 9s. Going to nine of them wraps the number to -73741825 and foils that behavior.)
See also UnfillRegion, UnwrapLine.
There is a whole bunch of unfilling functions in ourcomments-util.el in nXhtml. There is for example already a function unfill-region.