[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
`buffer-sentences'
From: |
Emanuel Berg |
Subject: |
`buffer-sentences' |
Date: |
Sun, 14 Jul 2024 20:13:04 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
I've been writing some Elisp, some of it turned up all-Emacs.
Maybe it already exists in Emacs or ELPA, if so I'd be happy
to use that instead. Are there any options?
If not, this is something that can be put somewhere. I'd like
to discuss what improvements can be made?
Here, one can also think of a general buffer parsing function,
where you could submit what unit you would like it to be split
up into.
(require 'cl-lib)
(require 'thingatpt)
(defun buffer-sentences (&optional beg end no-sort)
(or beg (setq beg (point-min)))
(or end (setq end (point-max)))
(save-mark-and-excursion
(goto-char beg)
(cl-loop
with buf-strs
with next-str
while (< (point) end) do
(setq next-str (sentence-at-point t))
(when next-str
(push next-str buf-strs) )
(forward-sentence)
finally return (if no-sort buf-strs (sort buf-strs)) )))
--
underground experts united
https://dataswamp.org/~incal
- `buffer-sentences',
Emanuel Berg <=