all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* `string-words'
@ 2024-07-14 18:09 Emanuel Berg
  2024-07-14 18:45 ` `string-words' Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: Emanuel Berg @ 2024-07-14 18:09 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 a candidate for a string library.

;;; -*- lexical-binding: t -*-

(defun string-words (str &optional no-sort keep-case)
  (or keep-case (setq str (downcase str)))
  (let ((words (split-string str "[[:space:]()]+" t "[[:punct:]]+")))
    (if no-sort
        words
      (sort words) )))

-- 
underground experts united
https://dataswamp.org/~incal




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

* Re: `string-words'
  2024-07-14 18:09 `string-words' Emanuel Berg
@ 2024-07-14 18:45 ` Eli Zaretskii
  2024-07-14 23:35   ` `string-words' Emanuel Berg
  0 siblings, 1 reply; 5+ 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:09: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-words.



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

* Re: `string-words'
  2024-07-14 18:45 ` `string-words' Eli Zaretskii
@ 2024-07-14 23:35   ` Emanuel Berg
  2024-07-15  2:29     ` `string-words' Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: Emanuel Berg @ 2024-07-14 23:35 UTC (permalink / raw)
  To: emacs-devel

Eli Zaretskii wrote:

> We have count-words.

Ah, no, this is about getting a list of words, so you can do
stuff with them.

Here is what I did with it, not anything for Emacs tho, ha:

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

-- 
underground experts united
https://dataswamp.org/~incal




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

* Re: `string-words'
  2024-07-14 23:35   ` `string-words' Emanuel Berg
@ 2024-07-15  2:29     ` Eli Zaretskii
  2024-07-15  3:32       ` `string-words' Emanuel Berg
  0 siblings, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2024-07-15  2:29 UTC (permalink / raw)
  To: Emanuel Berg; +Cc: emacs-devel

> From: Emanuel Berg <incal@dataswamp.org>
> Date: Mon, 15 Jul 2024 01:35:44 +0200
> 
> Eli Zaretskii wrote:
> 
> > We have count-words.
> 
> Ah, no, this is about getting a list of words, so you can do
> stuff with them.

In Emacs we prefer to "do stuff" on text directly in the buffer,
instead of first extracting the text as strings and then working with
those strings.



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

* Re: `string-words'
  2024-07-15  2:29     ` `string-words' Eli Zaretskii
@ 2024-07-15  3:32       ` Emanuel Berg
  0 siblings, 0 replies; 5+ messages in thread
From: Emanuel Berg @ 2024-07-15  3:32 UTC (permalink / raw)
  To: emacs-devel

Eli Zaretskii wrote:

>>> We have count-words.
>> 
>> Ah, no, this is about getting a list of words, so you can
>> do stuff with them.
>
> In Emacs we prefer to "do stuff" on text directly in the
> buffer, instead of first extracting the text as strings and
> then working with those strings.

Right, and I'm not against it for the situations where it is
preferable, of course.

-- 
underground experts united
https://dataswamp.org/~incal




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

end of thread, other threads:[~2024-07-15  3:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-14 18:09 `string-words' Emanuel Berg
2024-07-14 18:45 ` `string-words' Eli Zaretskii
2024-07-14 23:35   ` `string-words' Emanuel Berg
2024-07-15  2:29     ` `string-words' Eli Zaretskii
2024-07-15  3:32       ` `string-words' Emanuel Berg

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.