(defun unfill-paragraph (&optional region)
"Make a multi-paragraph REGION 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)))
;;; DeepAI produced code
(defun map-paragraph (func &optional beg end)
"Call FUNC on each paragraph in the region.
If BEG and END are not specified, the entire buffer is used.
BEG and END should be integers or markers, and they default to
the beginning and end of the buffer, respectively."
(save-excursion
(let ((start (or beg (point-min)))
(end (or end (point-max))))
(goto-char start)
(while (and (< (point) end)
(re-search-forward paragraph-start end t))
(let ((para-start (match-beginning 0))
(para-end (save-excursion
(goto-char para-start)
(forward-paragraph)
(min (point) end)))) ; don't go past the end of the region
(funcall func para-start para-end))))))
(require 'embark)
(defun embark-map-paragraph (func &rest _)
"Call FUNC on each paragraph in the region or buffer."
(map-paragraph func (region-beginning) (region-end)))
(embark-define-action map-paragraph embark-map-paragraph
"Call a function on each paragraph in the region or buffer.")
(embark-bind-action map-paragraph)