title: Problem creating a lstnewenvironment that starts/ends another environment
body: <p>I am currently using Beamer and the listing package to pretty-print code into Beamer blocks. So what I'm doing looks like :</p>
  
  <pre><code>\begin{block}{}
  \begin{lstlisting}
  int foobar(void) { return 0; }
  \end{lstlisting}
  \end{block}
  </code></pre>
  
  <p>Now, I find it cumbersome to start the <code>block</code> and <code>lstlisting</code> environments everytime. I'd like to have a simple <code>codeblock</code> environment that just does it:</p>
  
  <pre><code>\begin{codeblock}
  int foobar(void) { return 0; }
  \end{codeblock}
  </code></pre>
  
  <p>So, I tried something like :</p>
  
  <pre><code>\lstnewenvironment{codeblock}
  {\begin{block}{}}
  {\end{block}}
  </code></pre>
  
  <p>But unfortunately, the Beamer document no longer compiles, with the following error:</p>
  
  <pre><code>! Missing } inserted.
  &lt;inserted text&gt; 
                  }
  l.178 \end{frame}
  
  ? 
  </code></pre>
  
  <p>Is there some way to do this ?</p>
  
  <p>In <a href="https://stackoverflow.com/questions/2606794/problem-with-creating-a-newenvironment-in-latex">Problem with creating a newenvironment in LaTeX</a>, Andreas Grech had the same problem, but it could solve it since there was another way to enter/exit the enclosing environment. But in the case of the <code>block</code> Beamer environment, it seems there is no other way than doing <code>\begin{block}...\end{block}</code>.</p>