Similarly to this question, I would like the optional argument of the \item command to print the number of points. Since I don't want to define a new list environment or a custom \item command I tried the following code (inspired by this answer):
\documentclass{article}
\usepackage[shortlabels]{enumitem}
\usepackage{etoolbox,xparse}
\AtBeginEnvironment{enumerate}{\let\olditem\item%
\RenewDocumentCommand{\item}{o}{%
\IfValueTF{#1}{#1 points}\olditem}}
\begin{document}
\begin{enumerate}[1)]
\item This is some item
\item[10] This item is worth something
\item Another item
\end{enumerate}
\end{document}
However this doesn't work since it gives the result seen in the image. I'm obviously doing something (or several things wrong). Thanks in advance for the help.
BONUS: Ideally the solution should work with various enumerate levels (i.e nested environments).


\IfValueTF{#1}{\olditem[#1 points]}\olditem– Gonzalo Medina Oct 26 '15 at 22:38\item\points{10} First itemwhere you define\newcommand{\points}[1]{[#1 points]}? – egreg Oct 26 '15 at 23:25\itemcommand I thought that maybe I could redefine it and finally use it. – petobens Oct 27 '15 at 02:19\olditemis defined to the current, redefined\itemand then that is redefined in terms of\olditemwhich is defined in terms of.... Of course, it can be done. But it cannot possibly be worth doing. It will also make your code less readable and less flexible. – cfr Oct 27 '15 at 03:16\item[10 points]. You will see output different than what you are probably hoping for. If that is true, you'll need to think pretty carefully about many list-related spacing issues before coming up with a solution that will work correctly in nested lists. I also have to concur that a separate macro definition is the way to go. – jon Oct 27 '15 at 03:30