amsmath defines \dots which does a look-ahead and it uses different dots (vertically centred or not, basically) depending on the next token. See How do magic \dots work in amsmath?
However, because of this (at least, this is my understanding), it does not work when the dots are at the end of the formula:
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[ x + \dots + x + \dots \]
\end{document}
Now, it is not a big deal when using + because I can directly use \dotsb. However, custom commands can also be made "dots-aware":
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\newcommand*\myop{\DOTSB\rightarrow}
\[ x \myop \dots \myop x \myop \dots \]
\end{document}
In this case I would like the last \dots to automatically adjust itself depending on the definition of \myop. How can this be done?
I do not necessarily expect \dots to "remember" what happened before (though it would be nice), it would be ok to give it some kind of hint by repeating the operator after the dots:
\[ x \myop \dots \myop x \myop \dots \hint\myop \]
EDIT: or even better:
\[ x \myop \dots \myop x \myop \dotsfor{\myop} \]
Maybe a look-ahead macro looking at the first token of its argument could be used? Though it would not be just look-ahead, the rest of the argument should be discarded.

\dotsbfor this one occurrence? Any automated solution will have corner cases and frankly\dots\hint\myopis much longer to type than\dotsb. – Henri Menke Jan 31 '17 at 11:24\myopthen I have to find and replace all those occurrences of\dotsb. – effeffe Jan 31 '17 at 11:28\def\myopdots{\myop\dotsb}then? – Henri Menke Jan 31 '17 at 12:40