The easy way to answer that: \definemathcommand[dif][nolop]{\mfunction{d}} didn't work because it's intended for log-like functions, and you don't want a log-like function, but a differential, which behaves differently (for instance, you *want* space between the function and the argument in `\sin x \cos y` but you *don't want* spaces between the “d” and the variable in `\dif x \dif y`). About `\mfunction` I don't know, I think what's in the wiki is enough, it's the command that sets the font used for other upright functions (notice that some people prefer italic differentials hence the definition would be \define\dif{\mathop{}\!d}). And about how does that work, well, basically what you want is a thin space added on the left, but not on the right, so \mathop{} gives a thin space on both sides, then with \! you remove the thin space on the right and you then leave the \mfunction{d} with normal spacing. That definition behaves correctly in every case (except if you use “physics-like” notation where the differential comes just after \int). I hope I don't leave anything relevant out (but I'm no expert).