Remove certain actions/commands from History?

Could you (somehow) ‘tick off’ (or turn off) certain actions so they are not ‘undo-able’, so they do not show up in History?

For instance, switching between modes (ob., edit, sculpt, etc), or turning on/off X-ray display [would not show up in the Undo history], non-modeling stuff like that…