Comments (5)
(let* ((str "this is a test")
(sep " ")
(s-car (car (s-split sep str)))
(s-cdr (substring str (length (concat s-car sep)))))
(cons s-car s-cdr))
Something like this...
from s.el.
(defun s-split-cons (s &optional separator)
"Split S using SEPARATOR (defaults to space).
The return value is a `cons' cell with the first item of the
split as `car' and the rest of the string as `cdr'.
For example.
(s-split-cons \"this:that\" \":\")
=> (\"this\" . \"that\")
(s-split \"more than one\")
=> (\"more\" . \"than one\")
"
(declare (side-effect-free t))
(let* ((sep (or separator " "))
(s-car (car (s-split separator s)))
(s-cdr (substring s (+ 1 (length (concat s-car separator))))))
(cons s-car s-cdr)))
So I'll consider the utility of this one. It seems very niche tbh.
@Atlas48 Can you help me understand how this would be generally useful to many people. I struggled as I wrote the docstring to think of a use-case for this.
from s.el.
@magnars any thoughts on this?
from s.el.
I'm of the opinion that we should keep the s
api generally useful. There are a lot of features that could conceivably fit under the "string manipulation" umbrella. I'm wary of adding all of them to the bulk of code that we're maintaining.
In this specific case, I think I agree with you @jasonm23 that this seems quite niche.
from s.el.
I'm closing this as out of scope.
from s.el.
Related Issues (20)
- Speed Counting Matches: Unexpected Results
- Will s.el drop the support of Emacs 23? HOT 8
- Time for a new melpa-stable release? HOT 7
- Inclusion in Emacs HOT 12
- s-replace-all case-issue HOT 3
- Marmalade is dead, and the document should be updated correspondingly. HOT 1
- Cosmetic change to `s-trim-right`
- Wildcard match? HOT 1
- Is it dead... HOT 10
- Functions which use `save-match-data` `with-temp-buffer` - side-effect-free? HOT 4
- (s-unindent s &optional bol-char) HOT 4
- 🐣 [REQUEST] - s-url-encode / s-url-decode HOT 10
- 🪲 [BUG] - Under CI 26.{1..3} fail due to no marker in buffer HOT 2
- 🪲 [BUG] - create-docs.sh failing HOT 2
- 🪲 [BUG] - Emacs 24.4 & 24.5 fail tests on CI. HOT 3
- 🐣 [REQUEST] - add s-truncate-width HOT 3
- Use ETD as a development dependency for example/tests/docs
- RFC : Dropping support for Emacs versions below 26. HOT 4
- 🐣 [REQUEST] - Add a way to check the style of given string HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from s.el.