I have a Clojure listing and I want to colour certain keywords whereas I can only do for strings not including any dash ('-') or slash ('/). But I also need to consider keywords consisting of with dash and etc as well.
I have the following listing:
\documentclass[english,a4paper,12pt]{report}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{listings}
\usepackage{xcolor}
\input{listingsClojure}
\begin{document}
\begin{lstlisting}[
basicstyle={\fontsize{9}{10}\ttfamily},
mathescape=true,showstringspaces=false,
flexiblecolumns=true,
tabsize=2,
numbersep=1pt,
numbers=left,
xleftmargin=0.2cm,
framerule=0pt,language=Clojure
]
(defn NOAsp [?n1 ?n2]
"the numbers"
(l/all
(w/asp ?n1)
(equals ?n2 (.getSourceLocation ?n1))))
\end{lstlisting}
\end{document}
And my lstdefinelanguage Clojure file:
\usepackage{soul}
\usepackage{xcolor}
\lstdefinelanguage{Clojure} {
morekeywords={defn, equals,l,all,getSourceLocation,'w/asp'},
morestring=[b]",
morestring=[b]',
}
\lstdefinelanguage{none} {
keywords={},
alsoletter={+},
morekeywords={}
}
\newcommand{\fsize}{\fontsize{8pt}{0pt}\selectfont}
\newcommand{\fsizesmall}{\fontsize{7.5pt}{0pt}\selectfont\ttfamily}
\lstset{
basicstyle = \fsize,
identifierstyle = \fsize,
keywordstyle = \fsize\color[HTML]{71295b},
keywordstyle = [2]\fsize\bfseries \color[HTML]{859900},
commentstyle = \fsize\color[HTML]{839496},
stringstyle = \fsize\color[HTML]{2429c9},
lineskip={-2pt}
}
I would like to see 'l/all' and 'w/asp' and '.getSourceLocation' together in color. Now I only see the following keywords are coloured: 'l', 'all', 'defn' and 'getSourceLocation'. More clearly, the red blocks must be coloured together:


\documentclass{...}, the required\usepackage's,\begin{document}, and\end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. – jub0bs May 23 '14 at 08:10