unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* `buffer-sentences'
@ 2024-07-14 18:13 Emanuel Berg
  2024-07-14 18:45 ` `buffer-sentences' Eli Zaretskii
  0 siblings, 1 reply; 3+ messages in thread
From: Emanuel Berg @ 2024-07-14 18:13 UTC (permalink / raw)
  To: emacs-devel

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




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

end of thread, other threads:[~2024-07-14 23:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-14 18:13 `buffer-sentences' Emanuel Berg
2024-07-14 18:45 ` `buffer-sentences' Eli Zaretskii
2024-07-14 23:38   ` `buffer-sentences' Emanuel Berg

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).