emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: concat with separators ?


From: Tino Calancha
Subject: Re: concat with separators ?
Date: Sun, 28 May 2017 20:27:05 +0900 (JST)
User-agent: Alpine 2.20 (DEB 67 2015-01-07)



On Sun, 28 May 2017, Jean-Christophe Helary wrote:


On May 28, 2017, at 19:52, Tino Calancha <address@hidden> wrote:

That's roughly the definition of string-join in subr-x:

(defsubst string-join (strings &optional separator)
"Join all STRINGS using SEPARATOR."
(mapconcat 'identity strings separator))

Would it be acceptable to provide separators to concat or is it preferable to 
use string-join instead?

The latter.
Func. `concat' accepts any arbitrary number of sequences (not a list of
sequences as `string-join').

I know that, but subr-x is experimental (hence not documented in the manual) 
and having to use mapconcat just to add a separator seems not practical.
I wouldn't worry too much about `string-join' not being in the manual. It's going to keep there. If it's convenient for you feel free to use it.
Many people here like to use stuff from subr-x.el.

Or you can create in your package a `foo-string-join' (foo being your package prefix). Once you write your package manual, this function will be documented in the Emacs manual as well.

We cannot modify `concat' with a new argument `separator' without breaking existent code.
You can pass the separator between strings:

(concat "foo" ":" "bar" ":" "qux")
=> "foo:bar:qux"

Or use format:
(format "%s:%s:%s" "foo" "bar" "qux")
=> "foo:bar:qux"




reply via email to

[Prev in Thread] Current Thread [Next in Thread]