Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I want to remove a token from the stream from within a command (ignoring spaces). The next token will be a { (actually, I've just thought that it might not be ... but I'll continue as if it were). In "ordinary" TeX I would end the command with \let\junk=. LaTeX3 has lots of \peek_<something>_remove_ignore_spaces:NTF commands which would do it, except that there's an unnecessary conditional there which seems like overkill.

So what's the LaTeX3 equivalent of let\junk=?

share|improve this question
    
I don't think there is; \cs_new_protected:Npn \stacey_remove_token_ignore_spaces: { \peek_charcode_remove_ignore_spaces:NF \scan_stop: {} } –  egreg Jun 18 '13 at 12:50
    
IIRC, @egreg's suggestion will only remove the next token if it is a control sequence, no? There is no \let\junk= in LaTeX3, because it is quite rare that you wish to unconditionally remove whatever tokens follow, I believe. One option is always \cs_set_eq:NN \junk, but it is not very appealing. –  Bruno Le Floch Jul 7 '13 at 3:48
    
Could you expand the context here? As Bruno says, this is quite a rare thing to need to do other than inside \peek_... type constructs. –  Joseph Wright Aug 11 '13 at 19:14
    
@JosephWright The context is that I've just done an "If next char is X" test. I don't want to remove the token at that stage because if it isn't X then I need to keep it where it is. But if it is X then I want to ignore it and move on to the next token. –  Andrew Stacey Aug 11 '13 at 19:21
add comment

1 Answer

Sounds very much like you are after the 'peek and remove if true' functions, for example

\documentclass{article}
\usepackage{expl3}
\ExplSyntaxOn
\cs_new_protected:Npn \demo
  {
    \peek_meaning_remove:NTF a
      { Nope,~an~`a' \par }
      { It's~OK~ma,~it's~only~ } 
  }
\ExplSyntaxOff
\begin{document}

\demo ab

\demo c
\end{document}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.