all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* How to get all paragraphs in list?
@ 2022-09-05  4:15 Jean Louis
  2022-09-05  4:40 ` Teemu Likonen
                   ` (3 more replies)
  0 siblings, 4 replies; 20+ messages in thread
From: Jean Louis @ 2022-09-05  4:15 UTC (permalink / raw)
  To: Help GNU Emacs

I would like to get all paragraphs in a list, even if paragraphs are
separated by two or more spaces, I would still like those spaces.

Purpose of doing it is joining lines of such paragraph as to paste it
into website pages or chats. Wrapped lines do not look nice when
pasted. 

Starting function to join lines is this one:

(defun join-lines ()
  "Joins lines of a paragraph of 100000 chars."
  (interactive)
  (let ((old fill-column))
    (setq fill-column 100000)
    (fill-paragraph nil)
    (setq fill-column old)))

My starting point to get all paragraphs could be in this function:

(defun sort-paragraphs (reverse beg end)
  "Sort paragraphs in region alphabetically; argument means descending order.
Called from a program, there are three arguments:
REVERSE (non-nil means reverse order), BEG and END (region to sort).
The variable `sort-fold-case' determines whether alphabetic case affects
the sort order."
  (interactive "P\nr")
  (save-excursion
    (save-restriction
      (narrow-to-region beg end)
      (goto-char (point-min))
      (sort-subr reverse
		 (lambda ()
		   (while (and (not (eobp)) (looking-at paragraph-separate))
		     (forward-line 1)))
		 (lambda ()
                   (forward-paragraph)
                   ;; If the buffer doesn't end with a newline, add a
                   ;; newline to avoid having paragraphs being
                   ;; concatenated after sorting.
                   (when (and (eobp)
                              (not (bolp)))
                     (insert "\n")))))))

Is there any existing way to fetch all paragraphs (separated by two or
more spaces) in the list?


Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2022-09-16 19:04 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-05  4:15 How to get all paragraphs in list? Jean Louis
2022-09-05  4:40 ` Teemu Likonen
2022-09-05  5:12 ` Emanuel Berg
2022-09-05  9:13 ` Alessandro Bertulli
2022-09-05 16:40   ` Jean Louis
2022-09-06  1:31     ` Emanuel Berg
2022-09-16 14:18       ` Jean Louis
2022-09-16 14:21       ` Jean Louis
2022-09-05 16:02 ` [External] : " Drew Adams
2022-09-05 17:04   ` Jean Louis
2022-09-05 18:05     ` Drew Adams
2022-09-06 11:17       ` Jean Louis
2022-09-07  6:03       ` Jean Louis
2022-09-07  6:13         ` Emanuel Berg
2022-09-07 13:05         ` Yuri Khan
2022-09-07 15:04           ` Drew Adams
2022-09-07 23:51           ` Emanuel Berg
2022-09-16 16:17             ` Yuri Khan
2022-09-16 19:04               ` Jean Louis
2022-09-16 18:55             ` Jean Louis

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.