The long lost Emacs string manipulation library.
It's available on Melpa:
M-x package-install s
Or you can just dump s.el
in your load path somewhere.
[[ function-list ]]
[[ function-docs ]]
Imagine looking through the function list and seeing s-ends-with?
, but
s-starts-with?
is nowhere to be found. Why? Well, because Emacs already has
string-prefix-p
. Now you're starting out slightly confused, then have to go
somewhere else to dig for the command you were looking for.
The wrapping functions serve as both documentation for existing functions and makes for a consistent API.
-
inflections package provides functions for strings pluralization and singularization.
-
levenshtein package provides a function to calculate the Levenshtein distance between two strings.
-
string-utils is another general string manipulation library.
- Alias all functions ending in
?
(Tianxiang Xiong) - Add
s-blank-str?
(Aborn Jiang) - Several bugfixes
- Add
s-matched-positions-all
(ono hiroko)
- Add
s-wrap
(Johan Andersson) - Add
s-split-up-to
(Matus Goljer) - Fix
s-reverse
for Unicode combining characters. (Christopher Wellons)
- Add
s-count-matches
(Lars Andersen)
- Add
s-present?
ands-present?
(Johan Andersson) - Better handling of international characters
- Add
s-word-initials
(Sylvain Rousseau) - Better handling of camel cased strings (@Bruce-Connor)
- Add
s-pad-left
ands-pad-right
- Bugfixes for
s-format
(Nic Ferrier)
- Add
s-all-match-strings
(Geoff Gole) - Add
s-lex-format
(Nic Ferrier)
- Add
s-capitalized?
- Add
s-replace-all
- Add
s-slice-at
- Add
s-split
alias forsplit-string
(Rüdiger Sonderfeld) - Add
s-less?
predicate (Rüdiger Sonderfeld) - Add START parameter to
s-matches?
(Rüdiger Sonderfeld) - Bugfixes
- Add
s-numeric?
- Add
s-match
(Arthur Andersen) - Add
s-format
(Nic Ferrier) - Move .el files out of root to avoid problems with require.
-
Breaking change:
s-capitalize
now converts the first word's first character to upper case and the rest to lower case.s-titleize
works like the olds-capitalize
and capitalizes each word. (Johan Andersson) -
s-capitalized-words
ands-titleized-words
mirror this change.
- Arthur Andersen contributed
s-match
- Rolando contributed
s-shared-start
ands-shared-end
- Johan Andersson contributed
s-presence
,s-present?
and fixeds-titleize
vss-capitalize
- Nic Ferrier added
s-format
ands-lex-format
- Rüdiger Sonderfeld contributed
s-less?
,s-split
and several bugfixes. - Geoff Gole contributed
s-all-match-strings
- Sylvain Rousseau contributed
s-word-initials
- Lars Andersen contributed
s-count-matches
- ono hiroko contributed
s-matched-positions-all
Thanks!
Yes, please do. Pure functions in the string manipulation realm only,
please. There's a suite of tests in dev/examples.el
, so remember to add
tests for your function, or I might break it later.
You'll find the repo at:
https://github.com/magnars/s.el
Run the tests with
./run-tests.sh
Create the docs with
./create-docs.sh
I highly recommend that you install these as a pre-commit hook, so that the tests are always running and the docs are always in sync:
cp pre-commit.sh .git/hooks/pre-commit
Oh, and don't edit README.md
directly, it is auto-generated.
Change readme-template.md
or examples-to-docs.el
instead.
Copyright (C) 2012-2015 Magnar Sveen
Authors: Magnar Sveen [email protected] Keywords: strings
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.