I'm using the algpseudocode package with two custom commands, \Let and \LongState to handle automatic indentation of (broken) long lines in the spirit of Werner's answer, which uses \parbox to wrap the long line's content.
However, the following approach does not work well when the indentation level is more than one. Here is an example:
\documentclass{article}
\usepackage{algorithm}
\usepackage[noend]{algpseudocode}
\usepackage{calc}
% A command for defining assignments within the algorithmic environment which
% supports automatic indentation when the second argument is too long to fit
% on one line
\newcommand*{\Let}[2]{\State #1 $\gets$
\parbox[t]{\linewidth-\algorithmicindent-\widthof{ #1 $\gets$}}{#2\strut}}
% A \State command that supports automatic indentation when the argument's
% content is too long to fit on one line
\newcommand*{\LongState}[1]{\State
\parbox[t]{\linewidth-\algorithmicindent}{#1\strut}}
\begin{document}
\begin{algorithm}
\caption{This is some testing pseudo-code showing what happens with nested long
lines}
\begin{algorithmic}[1]
\Function{test}{$(x, y)$}
\Let{$a$}{some math expression}
\Let{$b$}{some very very long expression that doesn't fit on one line and is
even longer and longer}
\For{each $e$ in a list}
\Let{$l(e)$}{the length of element $e$}
\If{some condition on $l(e)$}
\LongState{run some complex sub-routine and get the result and this
description is very very long, long indeed...}
\Let{$a$}{some math expression}
\Let{$b$}{some very very long expression that doesn't fit on one
line and is even longer and longer}
\If{some other condition}
\Let{$c$}{another math expression}
\EndIf
\EndIf
\EndFor
\EndFunction
\end{algorithmic}
\end{algorithm}
\end{document}
The following renders as:

Line 3 is an example of a well broken long line, whereas lines 7 and 9 stretch out too far.
Edit: I initially encountered this problem when writing my PhD Thesis using the cam-thesis class and XeLaTeX. My setup is Fedora 17 with TeXLive 2013 as packaged by Jindrich Novy.
If I use Gonzalo Medina's answer and change the document's class to \documentclass{cam-thesis} (following is a MWE):
\documentclass{cam-thesis}
\usepackage{algorithm}
\usepackage[noend]{algpseudocode}
\usepackage{calc}
\usepackage{linegoal}
% A command for defining assignments within the algorithmic environment which
% supports automatic indentation when the second argument is too long to fit
% on one line
\newcommand*{\Let}[2]{\State #1 $\gets$
\parbox[t]{\linegoal}{#2\strut}}
% A \State command that supports automatic indentation when the argument's
% content is too long to fit on one line
\newcommand*{\LongState}[1]{\State
\parbox[t]{\linegoal}{#1\strut}}
\begin{document}
\begin{algorithm}
\caption{This is some testing pseudo-code showing what happens with nested long
lines}
\begin{algorithmic}[1]
\Function{test}{$(x, y)$}
\Let{$a$}{some math expression}
\Let{$b$}{some very very long expression that doesn't fit on one line and is
even longer and longer}
\For{each $e$ in a list}
\Let{$l(e)$}{the length of element $e$}
\If{some condition on $l(e)$}
\LongState{run some complex sub-routine and get the result and this
description is very very long, long indeed...}
\Let{$a$}{some math expression}
\Let{$b$}{some very very long expression that doesn't fit on one
line and is even longer and longer}
\If{some other condition}
\Let{$c$}{another math expression}
\EndIf
\EndIf
\EndFor
\EndFunction
\end{algorithmic}
\end{algorithm}
\end{document}
I get the following (cam-thesis with XeLaTeX):

Debugging this further, however, I found that the following combinations work:
cam-thesiswithpdfLaTeX:
articlewithXeLaTeX:
articlewithpdfLaTeX:
All three of the above options work fine, but I really need to use cam-thesis with XeLaTeX.

\documentclass{cam-thesis}your solution doesn't work. I'm new on TeX.SX and I don't know whether I should accept your answer and post a new question or resolve it all in one question? – tjanez Aug 26 '13 at 17:06cam-thesisclass is that you are usingpdfLaTeX, whereas I useXeLaTeX. I edited the question and gave full details of my setup. – tjanez Aug 26 '13 at 22:00linegoalseem not to like each other. I'll let you know if I can think of a solution for this case. – Gonzalo Medina Aug 26 '13 at 22:08\newcommand*{\Let}[2]{\State #1 $\gets$ \parbox[t]{-52,29pt+\linegoal}{#2\strut}} \newcommand*{\LongState}[1]{\State \parbox[t]{-52,29pt+\linegoal}{#1\strut}}. This will work, but you'll get a warning about labels. – Gonzalo Medina Aug 26 '13 at 22:21Latexmkgives me this error: "Did not finish processing file 'thesis': 'pdflatex' needed too many passes Latexmk: Use the -f option to force complete processing, unless error was exceeding maximum runs of latex/pdflatex." I can live with that but it would be nice if it could be fixed. – tjanez Aug 27 '13 at 11:59algpseudocodewas loaded by the OP with thenoendoption. Remove the option. – Gonzalo Medina Aug 29 '13 at 13:01