How to change appearance of a particular line when using \lstincludelisting?

I'm using the listings package and include code into my document through \lstincludelistings. The problem is that I want to set some code lines to bold to indicate changes from previous code segments.

How can I achieve this without having to copy-paste the code directly into the document?

-

A solution would be to define a macro that invokes \lstinputlisting three times (for the part before the line to emphasize, the line itself, and the part after the line to emphasize) and adopts the listing style with \lstset to achive the desired highlighting:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{listings}

\usepackage{xcolor}   % for coloring as emph
\usepackage{etoolbox} % for \ifnumcomp
\usepackage{beramono} % a tt font that has a boldface series

\lstset{basicstyle=\ttfamily}

% The style to be applied for the highlighted line:
\lstdefinestyle{highlight}{basicstyle=\ttfamily\bfseries\color{red}}
%\lstdefinestyle{highlight}{backgroundcolor=\color{orange!30}}

% input listing and emphasize a specific line
% \lstinputemph[listings options]{line number}{filename}
\newcommand{\lstinputemph}[3][\empty]{%
\lstset{aboveskip=0pt, belowskip=0pt, showlines=true,#1}%
\ifnumcomp{#2}{=}{0}{\lstinputlisting{#3}}{%
\ifnumcomp{#2}{=}{1}{}{\lstinputlisting[lastline=\the\numexpr#2-1\relax]{#3}}%
\lstinputlisting[firstnumber={#2},firstline={#2},lastline={#2},style=highlight]{#3}
\lstinputlisting[firstnumber={\the\numexpr#2+1},firstline=\the\numexpr#2+1\relax]{#3}
}% else
}

\begin{document}
\lstinputemph[language=C]{3}{hello.c}
\end{document}


With file hello.c as follows

#include <stdio.h>
void main() {
printf("Hello, World\n")
}


This lead to the following output (second example uses a different background color for the highlighting effect)

-
That's quite nifty! But what if I want to emphasize more than one line? –  gablin Sep 14 '11 at 10:54
@gablin: Then you should probably rephrase the title of your question ;-) No, seriously: (1) Do you need to just give a (e.g. comma-separated) list of lines (like 1,5,6,7,12) or do you also need ranges (like 1,5-7,12) (2) Do you insist on a font change to highlight the lines or would a different background color (as in my second example) be suitable. –  Daniel Sep 14 '11 at 20:11
Hm, yeah that would make it much harder. I actually ended up not emphasizing any lines at all, but you did answer my question so I'll accept your answer. –  gablin Sep 29 '11 at 19:36