There are several options for escaping LaTeX code in the lstlisting-environment. But this doesn't seem to work in \lstinline. I'd like to do something like this:
\lstinline[escapechar=§]{§\textlangle§foo§\textrangle§}
Is there any workaround?
Escaping via mathescape from listings works in \lstinline just the same as it does in the lstlisting environment. Here's a minimal example showing how to use it:

\documentclass{article}
\usepackage{listings}% http://ctan.org/pkg/listings
\begin{document}
\section{foo} \label{foo}
\lstinline[mathescape]!abc$ijk$xyz$\ref{foo}$23!
\end{document}
In the above example, ijk is set in math mode, since mathescape is true, while \ref{foo} is also, but prints as a reference to the first section. Note the delimiter choice ! rather than {...}, although the MWE also works with this.
From reading the code of the listings package, it is apparently deliberate but undocumented behaviour that escapes cannot be used in lstinline, with the exception of mathescape. Presumably escapes are considered an 'unsafe feature' in TextStyle contexts (of which lstinline is one), but it is not clear why or when it might be unsafe.
It is possible to re-enable the feature, as done below, but beware in case it causes any problems:
\documentclass{article}
\usepackage{listings}% http://ctan.org/pkg/listings
% http://tex.stackexchange.com/q/43526
% fix the apparently deliberate but undocumented behaviour of disabling escapes other than mathescape in TextStyle (used by \lstinline)
% there may be a good reason why this is disabled by default, so beware in case it causes any problems
\usepackage{etoolbox}
\makeatletter
\patchcmd{\lsthk@TextStyle}{\let\lst@DefEsc\@empty}{}{}{\errmessage{failed to patch}}
\makeatother
% for the example:
\usepackage{textcomp}% for \textlangle, \textrangle
\begin{document}
Experimental brace syntax: \lstinline[escapechar=§]{§\textlangle§foo§\textrangle§}
Standard delimiter syntax: \lstinline[escapechar=§]!§\textlangle§foo§\textrangle§!
\end{document}

{tabular}, the width of the escaped text is not taken into account which causes overlaps with the text which follows. For example, in \begin{tabular}{l}\lstinline[escapechar=§]{foo§bar§} text\end{tabular}, the words bar and text overlap.
– Philippe Goutet
Oct 30 '14 at 16:50
\documentclass{article} \usepackage{listings} \lstset{mathescape} \begin{document} \lstinline+$Hello world!$+ \end{document}Unfortunately, I don't see another solution! – Denis Bitouzé Sep 05 '12 at 10:11abcsince the delimiters!...!still remain intact. Yes, using\lstinline[mathescape]$...$will be weird, but it still works (using my MWE). – Werner Mar 12 '14 at 17:12\text{ijk}macro from amsmath package, you can also include normal text into math mode. So this answer can be used in a more general way, like\lstinline[mathescape]!abc$\text{ijk}$xyz!. – John May 01 '18 at 15:02