From: Bozhidar Batsov <bozhidar@batsov.com>
To: Lars Magne Ingebrigtsen <larsi@gnus.org>
Cc: emacs-devel <emacs-devel@gnu.org>
Subject: Re: [PATCH] * lisp/subr.el (string-suffix-p): New function.
Date: Fri, 22 Nov 2013 12:41:00 +0200 [thread overview]
Message-ID: <CAM9Zgm2j2Mxb7jjJorEqXyQUd3VNr0ukda6ZipcAp8Mfstxj1g@mail.gmail.com> (raw)
In-Reply-To: <m3bo1coi7t.fsf@stories.gnus.org>
[-- Attachment #1: Type: text/plain, Size: 1729 bytes --]
On 22 November 2013 12:15, Lars Magne Ingebrigtsen <larsi@gnus.org> wrote:
> Bozhidar Batsov <bozhidar@batsov.com> writes:
>
> > I think it's quite important to provide an API closer to that of
> > popular programming languages, used often for text processing(Perl,
> > Python, Ruby, etc). That would include functions like:
> >
> > * string-join
>
> `mapconcat'
>
You can't really favour this:
(mapconcat 'identity '(s1 s2 s3) separator)
over:
(defun string-join (separator &rest strings)
(mapconcat 'identity strings separator))
(string-join separator s1 s2 s3)
>
> > * string-trim/string-trim-left/string-trim-right
>
> Perhaps.
>
> > * string-chop
>
> `split-string'
>
I'm not sure what split-string has to do with this?
From Ruby's API docs (
http://www.ruby-doc.org/core-1.9.3/String.html#method-i-chop):
Returns a new String with the last character removed. If the string ends
with \r\n, both characters are removed. Applying chop to an empty string
returns an empty string.String#chomp is often a safer alternative, as it
leaves the string unchanged if it doesn’t end in a record separator.
It's available in most scripting languages.
>
> > * string-chomp
>
> What does that do?
>
"hello".chomp #=> "hello"
"hello\n".chomp #=> "hello"
"hello\r\n".chomp #=> "hello"
"hello\n\r".chomp #=> "hello\n"
"hello\r".chomp #=> "hello"
"hello \n there".chomp #=> "hello \n there"
"hello".chomp("llo") #=> "he"
It's origin is Perl, but it's available in most scripting languages.
>
> --
> (domestic pets only, the antidote for overdose, milk.)
> bloggy blog: http://lars.ingebrigtsen.no
>
[-- Attachment #2: Type: text/html, Size: 3557 bytes --]
next prev parent reply other threads:[~2013-11-22 10:41 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-20 11:24 [PATCH] * lisp/subr.el (string-suffix-p): New function Bozhidar Batsov
2013-11-22 7:06 ` Bozhidar Batsov
2013-11-22 9:12 ` Thien-Thi Nguyen
2013-11-22 10:00 ` Bozhidar Batsov
2013-11-22 10:15 ` Lars Magne Ingebrigtsen
2013-11-22 10:41 ` Bozhidar Batsov [this message]
2013-11-22 14:07 ` Stefan Monnier
2013-11-22 14:27 ` Bozhidar Batsov
2013-11-23 1:44 ` Stefan Monnier
2013-11-23 6:05 ` Josh
2013-11-23 13:57 ` Stefan Monnier
2013-11-23 10:16 ` Stephen J. Turnbull
2013-11-23 17:03 ` Lars Magne Ingebrigtsen
2013-11-22 15:06 ` Jarek Czekalski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAM9Zgm2j2Mxb7jjJorEqXyQUd3VNr0ukda6ZipcAp8Mfstxj1g@mail.gmail.com \
--to=bozhidar@batsov.com \
--cc=emacs-devel@gnu.org \
--cc=larsi@gnus.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).