I want to change the usual role of : and \colon. Consider the following code
\documentclass{scrreprt}
\usepackage{amsmath}
\usepackage{unicode-math}
%\unimathsetup{colon=literal}
%\DeclareMathSymbol{:}{\mathpunct}{operators}{"3A}
%\let\colon\relax
%\DeclareMathSymbol{\colon}{\mathrel}{operators}{"3A}
\begin{document}
\newcommand\mycolon{\mathpunct{\char"003A}}
\newcommand\myratio{\mathrel{\char"003A}}
\( \pi:X \to Y \) (1)
\( \pi\myratio X \to Y \) (2)
\( \pi\colon X \to Y \) (3)
\( \pi\mycolon X \to Y \) (4)
\end{document}
The first two have the same gap between $\pi$ und $X$. (3) has less space and (4) the least amount. Remember the spacing of (3). Now uncomment the lines to interchange the role of ':' and \colon. Through now (1') is now correctly set as a punctation, the spacing is equal to (4') and NOT equal to the previous space of (3). Is there a way to adjust them?
EDIT: Solution due to egreg (with minimal changes)
\documentclass{scrreprt}
\usepackage{amsmath}
\usepackage{unicode-math}
\usepackage{etoolbox}
\patchcmd{\colon}{:}{\relcolon}{}{} % Remove ':' from the definition of \colon
\newcommand\myratio{\mathrel{\char"02236}} % Define how the colon should look like as a ratio
%\newcommand\myratio{\mathrel{\char"003A}} % Use for wider space
\AtBeginDocument{
\edef\relcolon % Define \recolon with current ':'
{\mathrel{\Umathcharnum\the\Umathcodenum`:}}
\begingroup\lccode`~=`: % Make ':' math-active and redefine it to be \colon
\lowercase{\endgroup\let~}\colon
\mathcode`:="8000
\let\colon\myratio % Redefine \colon with \myratio
}
\begin{document}
\( \pi:X \to Y \) (1)
\( \pi\colon X \to Y \) (2)
\end{document}


\colonwith a custom implementation (e.g\mathrel{\char"02236}) to completely finish the interchange. (see my original post for the complete solution) Also, thanks for the warning about the change of semantics. I'm aware of the limits, but I think this is a better solution then to write every function definition with a\colon, because this clutters the code. – Tobias Diez Oct 29 '13 at 08:43\char"02236is more appropriate, as it really stands for the relational colon. (Also there is a slight difference between your solution and mine, at least in Minion Pro) – Tobias Diez Oct 29 '13 at 09:01;-)– egreg Dec 08 '13 at 15:05