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

* Re: `buffer-sentences'
  2024-07-14 18:13 `buffer-sentences' Emanuel Berg
@ 2024-07-14 18:45 ` Eli Zaretskii
  2024-07-14 23:38   ` `buffer-sentences' Emanuel Berg
  0 siblings, 1 reply; 3+ messages in thread
From: Eli Zaretskii @ 2024-07-14 18:45 UTC (permalink / raw)
  To: Emanuel Berg; +Cc: emacs-devel

> From: Emanuel Berg <incal@dataswamp.org>
> Date: Sun, 14 Jul 2024 20:13:04 +0200
> 
> 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?

We have count-sentences.



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

* Re: `buffer-sentences'
  2024-07-14 18:45 ` `buffer-sentences' Eli Zaretskii
@ 2024-07-14 23:38   ` Emanuel Berg
  0 siblings, 0 replies; 3+ messages in thread
From: Emanuel Berg @ 2024-07-14 23:38 UTC (permalink / raw)
  To: emacs-devel

Eli Zaretskii wrote:

>> 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?
>
> We have count-sentences.

This is also not about counting but getting the data to do
cool stuff with it.

By all means, if you have it in a list, you can do `length' to
count them as well, but that wasn't the (only) thing so I
"had to" write it:

  https://dataswamp.org/~incal/emacs-init/b-a-original.el

-- 
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).