I want to combine the automatic punctuation in comma separated list from this answer with the list processing from etoolbox.
However, I do not get any output.
What is going wrong here?
\documentclass{article}
\usepackage{xparse,environ,xspace,etoolbox}
\ExplSyntaxOn
\NewEnviron{commalist}[1][\space]{\spence_comma_list:V \BODY #1}
\seq_new:N \l_spence_items_seq
\cs_new_protected:Npn \spence_comma_list:n #1
{
\seq_set_split:Nnn \l_spence_items_seq { \item } { #1 }
\seq_pop_left:NN \l_spence_items_seq \l_tmpa_tl % we have an empty element at the beginning
\seq_use:Nnnn \l_spence_items_seq { ~ and ~ } { , ~ } { , ~ and ~ }
}
\cs_generate_variant:Nn \spence_comma_list:n { V }
\ExplSyntaxOff
\begin{document}
The new list works:
\begin{commalist}
\item a
\item b
\item c
\end{commalist}
List processing from etoolbox works:
\forcsvlist{;}{a,b,c}
The combination does not work:
\begin{commalist}
\forcsvlist{\item}{a,b,c}
\end{commalist}
\end{document}



commalistenvironment, if you are providing input in the form of a comma separated list. Would an answer that takes a comma separated list and turns it intoa, b and cbe equally acceptable? – Steven B. Segletes May 05 '21 at 13:11bibtexfield containing a comma separated list. I am reading it using\forcsvfieldfrombiblatexwhich is modeled after\forcsvlistfrometoolbox. I want to include anandbefore the last item, but are also considering using a totally different separator, maybe a semicolon. If there is a better way to do it, I will gladly accept it. – Jan Hajer May 05 '21 at 13:18