all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Emanuel Berg <incal@dataswamp.org>
To: emacs-devel@gnu.org
Subject: `buffer-sentences'
Date: Sun, 14 Jul 2024 20:13:04 +0200	[thread overview]
Message-ID: <87frsbetan.fsf@dataswamp.org> (raw)

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




             reply	other threads:[~2024-07-14 18:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-14 18:13 Emanuel Berg [this message]
2024-07-14 18:45 ` `buffer-sentences' Eli Zaretskii
2024-07-14 23:38   ` `buffer-sentences' Emanuel Berg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87frsbetan.fsf@dataswamp.org \
    --to=incal@dataswamp.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.