* Tools for those working heavily with strings
@ 2022-07-24 5:04 carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-24 5:11 ` Jean Louis
0 siblings, 1 reply; 15+ messages in thread
From: carlmarcos--- via Users list for the GNU Emacs text editor @ 2022-07-24 5:04 UTC (permalink / raw)
To: Help Gnu Emacs
If one works heavily with strings, it is often strongly recommend to use Magnar Sveen `s.el' string manipulation library.
Can emacs have its own string manipulation tools. It would be much appreciated.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Tools for those working heavily with strings
2022-07-24 5:04 Tools for those working heavily with strings carlmarcos--- via Users list for the GNU Emacs text editor
@ 2022-07-24 5:11 ` Jean Louis
2022-07-24 5:17 ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-24 8:44 ` Jean Louis
0 siblings, 2 replies; 15+ messages in thread
From: Jean Louis @ 2022-07-24 5:11 UTC (permalink / raw)
To: carlmarcos; +Cc: Help Gnu Emacs
* carlmarcos--- via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> [2022-07-24 08:06]:
> If one works heavily with strings, it is often strongly recommend to use Magnar Sveen `s.el' string manipulation library.
>
> Can emacs have its own string manipulation tools. It would be much
> appreciated.
74 possible completions for functions with prefix `string-':
string-add string-add-space string-as-multibyte string-as-unibyte
string-blank-if-nil string-blank-p string-bytes string-chop-newline
string-clean-whitespace string-collate-equalp string-collate-lessp
string-comma-space string-comma-space-cast-text
string-comma-space-list string-comma-space-quoted
string-comma-space-quoted-list string-cut-id string-cut-id-with-part
string-cut-right-square-bracket-reference string-distance string-edit
string-empty-p string-equal string-fill string-glyph-compose
string-glyph-decompose string-glyph-split string-greaterp
string-insert-rectangle string-is-number-p
string-is-positive-integer-p string-join string-last-part-after-space
string-lessp string-limit string-lines string-make-multibyte
string-make-unibyte string-match string-match-p
string-number-smaller-p string-or-empty-string string-or-null-p
string-pad string-pixel-width string-prefix-p string-rectangle
string-remove-prefix string-remove-suffix string-replace
string-replace-non-digits-for-spaces string-replace-shorten-spaces
string-reverse string-search string-slug string-slug-region
string-suffix-p string-to-char string-to-double-quotes
string-to-file-force string-to-list string-to-multibyte
string-to-number string-to-single-quotes string-to-syntax
string-to-unibyte string-to-vector string-trim string-trim-left
string-trim-right string-truncate-left string-version-lessp
string-width string-words-to-double-quotes
--
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
In support of Richard M. Stallman
https://stallmansupport.org/
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Tools for those working heavily with strings
2022-07-24 5:11 ` Jean Louis
@ 2022-07-24 5:17 ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-24 8:45 ` Jean Louis
2022-07-24 8:44 ` Jean Louis
1 sibling, 1 reply; 15+ messages in thread
From: carlmarcos--- via Users list for the GNU Emacs text editor @ 2022-07-24 5:17 UTC (permalink / raw)
To: Jean Louis; +Cc: Help Gnu Emacs
Jul 24, 2022, 05:11 by bugs@gnu.support:
> * carlmarcos--- via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> [2022-07-24 08:06]:
>
>> If one works heavily with strings, it is often strongly recommend to use Magnar Sveen `s.el' string manipulation library.
>>
>> Can emacs have its own string manipulation tools. It would be much
>> appreciated.
>>
>
> 74 possible completions for functions with prefix `string-':
>
Why the popular recommendation for `s.el` then?
> string-add string-add-space string-as-multibyte string-as-unibyte
> string-blank-if-nil string-blank-p string-bytes string-chop-newline
> string-clean-whitespace string-collate-equalp string-collate-lessp
> string-comma-space string-comma-space-cast-text
> string-comma-space-list string-comma-space-quoted
> string-comma-space-quoted-list string-cut-id string-cut-id-with-part
> string-cut-right-square-bracket-reference string-distance string-edit
> string-empty-p string-equal string-fill string-glyph-compose
> string-glyph-decompose string-glyph-split string-greaterp
> string-insert-rectangle string-is-number-p
> string-is-positive-integer-p string-join string-last-part-after-space
> string-lessp string-limit string-lines string-make-multibyte
> string-make-unibyte string-match string-match-p
> string-number-smaller-p string-or-empty-string string-or-null-p
> string-pad string-pixel-width string-prefix-p string-rectangle
> string-remove-prefix string-remove-suffix string-replace
> string-replace-non-digits-for-spaces string-replace-shorten-spaces
> string-reverse string-search string-slug string-slug-region
> string-suffix-p string-to-char string-to-double-quotes
> string-to-file-force string-to-list string-to-multibyte
> string-to-number string-to-single-quotes string-to-syntax
> string-to-unibyte string-to-vector string-trim string-trim-left
> string-trim-right string-truncate-left string-version-lessp
> string-width string-words-to-double-quotes
>
> --
> Jean
>
> Take action in Free Software Foundation campaigns:
> https://www.fsf.org/campaigns
>
> In support of Richard M. Stallman
> https://stallmansupport.org/
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Tools for those working heavily with strings
2022-07-24 5:11 ` Jean Louis
2022-07-24 5:17 ` carlmarcos--- via Users list for the GNU Emacs text editor
@ 2022-07-24 8:44 ` Jean Louis
2022-07-24 11:12 ` carlmarcos--- via Users list for the GNU Emacs text editor
1 sibling, 1 reply; 15+ messages in thread
From: Jean Louis @ 2022-07-24 8:44 UTC (permalink / raw)
To: carlmarcos; +Cc: Help Gnu Emacs
Sorry, many of those functions were not from Emacs, but mine.
However, I manipulate strings and I don't reneger ever using s.el
Jean
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Tools for those working heavily with strings
2022-07-24 5:17 ` carlmarcos--- via Users list for the GNU Emacs text editor
@ 2022-07-24 8:45 ` Jean Louis
0 siblings, 0 replies; 15+ messages in thread
From: Jean Louis @ 2022-07-24 8:45 UTC (permalink / raw)
To: carlmarcos,
carlmarcos--- via Users list for the GNU Emacs text editor
Cc: Help Gnu Emacs
But look, you don't take a library because of library, but you take it easy it is practically useful for your purpose.
Jean
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Tools for those working heavily with strings
2022-07-24 8:44 ` Jean Louis
@ 2022-07-24 11:12 ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-24 11:26 ` tomas
2022-07-24 20:00 ` Jean Louis
0 siblings, 2 replies; 15+ messages in thread
From: carlmarcos--- via Users list for the GNU Emacs text editor @ 2022-07-24 11:12 UTC (permalink / raw)
To: Jean Louis; +Cc: Help Gnu Emacs
Jul 24, 2022, 08:44 by bugs@gnu.support:
> Sorry, many of those functions were not from Emacs, but mine.
>
> However, I manipulate strings and I don't reneger ever using s.el
>
> Jean
>
I'd appreciate if emacs could provide a minimum set of functions to manipulate list,
as string manipulations are of good use.
What can be introduced, you think?
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Tools for those working heavily with strings
2022-07-24 11:12 ` carlmarcos--- via Users list for the GNU Emacs text editor
@ 2022-07-24 11:26 ` tomas
2022-07-24 11:42 ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-24 20:00 ` Jean Louis
1 sibling, 1 reply; 15+ messages in thread
From: tomas @ 2022-07-24 11:26 UTC (permalink / raw)
To: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 401 bytes --]
On Sun, Jul 24, 2022 at 01:12:39PM +0200, carlmarcos--- via Users list for the GNU Emacs text editor wrote:
[...]
> I'd appreciate if emacs could provide a minimum set of functions to manipulate list,
> as string manipulations are of good use.
Why do you always refuse to read the docs?
> What can be introduced, you think?
What is missing, from your point of view?
cheers
--
t
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Tools for those working heavily with strings
2022-07-24 11:26 ` tomas
@ 2022-07-24 11:42 ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-24 13:11 ` Arash Esbati
` (2 more replies)
0 siblings, 3 replies; 15+ messages in thread
From: carlmarcos--- via Users list for the GNU Emacs text editor @ 2022-07-24 11:42 UTC (permalink / raw)
To: tomas; +Cc: help-gnu-emacs
Jul 24, 2022, 11:26 by tomas@tuxteam.de:
> On Sun, Jul 24, 2022 at 01:12:39PM +0200, carlmarcos--- via Users list for the GNU Emacs text editor wrote:
>
> [...]
>
>> I'd appreciate if emacs could provide a minimum set of functions to manipulate list,
>> as string manipulations are of good use.
>>
>
> Why do you always refuse to read the docs?
>
>> What can be introduced, you think?
>>
>
> What is missing, from your point of view?
>
What can I use to test whether a string in composed of whitespace or is empty?
> cheers
> --
> t
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Tools for those working heavily with strings
2022-07-24 11:42 ` carlmarcos--- via Users list for the GNU Emacs text editor
@ 2022-07-24 13:11 ` Arash Esbati
2022-07-24 13:17 ` tomas
2022-07-24 20:04 ` Jean Louis
2 siblings, 0 replies; 15+ messages in thread
From: Arash Esbati @ 2022-07-24 13:11 UTC (permalink / raw)
To: carlmarcos--- via Users list for the GNU Emacs text editor
Cc: tomas, carlmarcos
carlmarcos--- via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> writes:
> What can I use to test whether a string in composed of whitespace or
> is empty?
I'm not sure if I understand the "composed of whitespace" part
correctly, but you can try:
(let ((s "With space"))
(and (string-match " " s)
(message "With space")))
(let ((s " "))
(and (string-match "\\`[[:space:]]*\\'" s)
(message "Only spaces")))
(let ((s ""))
(and (string= s "")
(message "Empty string")))
(let ((s ""))
(and (= (length s) 0)
(message "Empty string")))
Best, Arash
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Tools for those working heavily with strings
2022-07-24 11:42 ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-24 13:11 ` Arash Esbati
@ 2022-07-24 13:17 ` tomas
2022-07-24 13:20 ` Philip Kaludercic
2022-07-24 20:04 ` Jean Louis
2 siblings, 1 reply; 15+ messages in thread
From: tomas @ 2022-07-24 13:17 UTC (permalink / raw)
To: carlmarcos; +Cc: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 837 bytes --]
On Sun, Jul 24, 2022 at 01:42:14PM +0200, carlmarcos@tutanota.com wrote:
> Jul 24, 2022, 11:26 by tomas@tuxteam.de:
>
> > On Sun, Jul 24, 2022 at 01:12:39PM +0200, carlmarcos--- via Users list for the GNU Emacs text editor wrote:
> >
> > [...]
> >
> >> I'd appreciate if emacs could provide a minimum set of functions to manipulate list,
> >> as string manipulations are of good use.
> >>
> >
> > Why do you always refuse to read the docs?
> >
> >> What can be introduced, you think?
> >>
> >
> > What is missing, from your point of view?
> >
> What can I use to test whether a string in composed of whitespace or is empty?
Try (string-match-p "^[[:space:]]*$" your-string-here)
If you want it to only match "horizontal white space" (i.e. no newlines,
no vertical tabs), try :blank: instead.
Cheers
--
t
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Tools for those working heavily with strings
2022-07-24 13:17 ` tomas
@ 2022-07-24 13:20 ` Philip Kaludercic
2022-07-24 13:23 ` tomas
0 siblings, 1 reply; 15+ messages in thread
From: Philip Kaludercic @ 2022-07-24 13:20 UTC (permalink / raw)
To: tomas; +Cc: carlmarcos, help-gnu-emacs
tomas@tuxteam.de writes:
> On Sun, Jul 24, 2022 at 01:42:14PM +0200, carlmarcos@tutanota.com wrote:
>> Jul 24, 2022, 11:26 by tomas@tuxteam.de:
>>
>> > On Sun, Jul 24, 2022 at 01:12:39PM +0200, carlmarcos--- via Users
>> > list for the GNU Emacs text editor wrote:
>> >
>> > [...]
>> >
>> >> I'd appreciate if emacs could provide a minimum set of functions
>> >> to manipulate list,
>> >> as string manipulations are of good use.
>> >>
>> >
>> > Why do you always refuse to read the docs?
>> >
>> >> What can be introduced, you think?
>> >>
>> >
>> > What is missing, from your point of view?
>> >
>> What can I use to test whether a string in composed of whitespace or is empty?
>
> Try (string-match-p "^[[:space:]]*$" your-string-here)
Or `string-empty-p'.
> If you want it to only match "horizontal white space" (i.e. no newlines,
> no vertical tabs), try :blank: instead.
>
> Cheers
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Tools for those working heavily with strings
2022-07-24 13:20 ` Philip Kaludercic
@ 2022-07-24 13:23 ` tomas
2022-07-24 14:45 ` Philip Kaludercic
0 siblings, 1 reply; 15+ messages in thread
From: tomas @ 2022-07-24 13:23 UTC (permalink / raw)
To: Philip Kaludercic; +Cc: carlmarcos, help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 987 bytes --]
On Sun, Jul 24, 2022 at 01:20:47PM +0000, Philip Kaludercic wrote:
> tomas@tuxteam.de writes:
>
> > On Sun, Jul 24, 2022 at 01:42:14PM +0200, carlmarcos@tutanota.com wrote:
> >> Jul 24, 2022, 11:26 by tomas@tuxteam.de:
> >>
> >> > On Sun, Jul 24, 2022 at 01:12:39PM +0200, carlmarcos--- via Users
> >> > list for the GNU Emacs text editor wrote:
> >> >
> >> > [...]
> >> >
> >> >> I'd appreciate if emacs could provide a minimum set of functions
> >> >> to manipulate list,
> >> >> as string manipulations are of good use.
> >> >>
> >> >
> >> > Why do you always refuse to read the docs?
> >> >
> >> >> What can be introduced, you think?
> >> >>
> >> >
> >> > What is missing, from your point of view?
> >> >
> >> What can I use to test whether a string in composed of whitespace or is empty?
> >
> > Try (string-match-p "^[[:space:]]*$" your-string-here)
>
> Or `string-empty-p'.
But this is only good for "", not for whitespace, right?
Cheers
--
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Tools for those working heavily with strings
2022-07-24 13:23 ` tomas
@ 2022-07-24 14:45 ` Philip Kaludercic
0 siblings, 0 replies; 15+ messages in thread
From: Philip Kaludercic @ 2022-07-24 14:45 UTC (permalink / raw)
To: tomas; +Cc: carlmarcos, help-gnu-emacs
tomas@tuxteam.de writes:
> On Sun, Jul 24, 2022 at 01:20:47PM +0000, Philip Kaludercic wrote:
>> tomas@tuxteam.de writes:
>>
>> > On Sun, Jul 24, 2022 at 01:42:14PM +0200, carlmarcos@tutanota.com wrote:
>> >> Jul 24, 2022, 11:26 by tomas@tuxteam.de:
>> >>
>> >> > On Sun, Jul 24, 2022 at 01:12:39PM +0200, carlmarcos--- via Users
>> >> > list for the GNU Emacs text editor wrote:
>> >> >
>> >> > [...]
>> >> >
>> >> >> I'd appreciate if emacs could provide a minimum set of functions
>> >> >> to manipulate list,
>> >> >> as string manipulations are of good use.
>> >> >>
>> >> >
>> >> > Why do you always refuse to read the docs?
>> >> >
>> >> >> What can be introduced, you think?
>> >> >>
>> >> >
>> >> > What is missing, from your point of view?
>> >> >
>> >> What can I use to test whether a string in composed of whitespace
>> >> or is empty?
>> >
>> > Try (string-match-p "^[[:space:]]*$" your-string-here)
>>
>> Or `string-empty-p'.
>
> But this is only good for "", not for whitespace, right?
Yes, my bad I always mix it up with string-blank-p from subr-x.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Tools for those working heavily with strings
2022-07-24 11:12 ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-24 11:26 ` tomas
@ 2022-07-24 20:00 ` Jean Louis
1 sibling, 0 replies; 15+ messages in thread
From: Jean Louis @ 2022-07-24 20:00 UTC (permalink / raw)
To: carlmarcos; +Cc: Help Gnu Emacs
* carlmarcos--- via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> [2022-07-24 14:13]:
> I'd appreciate if emacs could provide a minimum set of functions to manipulate list,
> as string manipulations are of good use.
It is there.
Do following: {M-x shortdoc-display-group RET list RET} for lists or
{M-x shortdoc-display-group RET string RET} for strings.
The above information within curly brackets are Hyperbole links, you
can activate them with packag Hyperbole by using M-RET
I can see that s.el has functions like `s-trim-left' and such
functions are in Emacs as `string-trim' and `string-trim-left' and so
on.
Function `s-collapse-whitespace' from s.el is in Emacs
`string-clean-whitespace'.
Function `s-split' is `split-string' in Emacs.
Function `s-lines' is `string-lines' in Emacs.
And so on, there are various functions that already exist in Emacs.
Just browse the `list' and `string' groups as above explained.
--
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
In support of Richard M. Stallman
https://stallmansupport.org/
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Tools for those working heavily with strings
2022-07-24 11:42 ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-24 13:11 ` Arash Esbati
2022-07-24 13:17 ` tomas
@ 2022-07-24 20:04 ` Jean Louis
2 siblings, 0 replies; 15+ messages in thread
From: Jean Louis @ 2022-07-24 20:04 UTC (permalink / raw)
To: carlmarcos; +Cc: tomas, help-gnu-emacs
* carlmarcos--- via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> [2022-07-24 14:43]:
> What can I use to test whether a string in composed of whitespace or is empty?
string-empty-p is a byte-compiled Lisp function in ‘simple.el’.
(string-empty-p STRING)
(string-empty-p "") ⇒ t
But for my understanding string may be considered empty if it has
white space only, thus:
(string-blank-p " ") ⇒ 0
string-blank-p is a byte-compiled Lisp function in ‘subr-x.el’.
(string-blank-p STRING)
Check whether STRING is either empty or only whitespace.
The following characters count as whitespace here: space, tab, newline and
carriage return.
--
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
In support of Richard M. Stallman
https://stallmansupport.org/
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2022-07-24 20:04 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-24 5:04 Tools for those working heavily with strings carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-24 5:11 ` Jean Louis
2022-07-24 5:17 ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-24 8:45 ` Jean Louis
2022-07-24 8:44 ` Jean Louis
2022-07-24 11:12 ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-24 11:26 ` tomas
2022-07-24 11:42 ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-24 13:11 ` Arash Esbati
2022-07-24 13:17 ` tomas
2022-07-24 13:20 ` Philip Kaludercic
2022-07-24 13:23 ` tomas
2022-07-24 14:45 ` Philip Kaludercic
2022-07-24 20:04 ` Jean Louis
2022-07-24 20:00 ` Jean Louis
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).