[Tex/LaTex] Using current path position in coordinate calculation

coordinatestikz-pgf

I often find myself writing code like this:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
  \node (aNodeWithALongName) at (1,1) {a};
  \node (bNodeWithALongName) at (1,-1) {b};
  \node (c) at (0,0) {c};

  \draw[->] (aNodeWithALongName) -- (aNodeWithALongName -| c);
  \draw[->] (bNodeWithALongName) -- (bNodeWithALongName -| c);
\end{tikzpicture}
\end{document}

I'm drawing a path, and need to use the first point's position to compute the second point, and I would like to avoid repeating the aNodeWithALongName, like this for example:

  \draw[->] (aNodeWithALongName) -- (current -| c);
  \draw[->] (bNodeWithALongName) -- (current -| c);

And more complex stuff:

  \draw[->] ($(aNodeWithALongName)!.5!(bNodeWithALongName)$) -- (current -| c);
  \draw[->] (bNodeWithALongName) -- ++(0, 1cm) -- (current -| c);

Is there a syntax similar to that which I could use?

Best Answer

I found a solution in this TeX-SX answer:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\makeatletter
\newcommand\currentcoordinate{\the\tikz@lastxsaved,\the\tikz@lastysaved}
\makeatother
\begin{document}
\begin{tikzpicture}
  \node (aNodeWithALongName) at (1,1) {a};
  \node (bNodeWithALongName) at (1,-1) {b};
  \node (c) at (0,0) {c};

  \draw[->] (aNodeWithALongName) -- (\currentcoordinate -| c);
  \draw[->] (bNodeWithALongName) -- (\currentcoordinate -| c);

  \draw[->] ($(aNodeWithALongName)!.5!(bNodeWithALongName)$) -- (\currentcoordinate -| c);
  \draw[->] (bNodeWithALongName) -- ++(0, 1cm) -- (\currentcoordinate -| c);
\end{tikzpicture}
\end{document}