I'm interested in a macro \nullifyifmoved that takes one argument arg and acts like arg in normal contexts, except it acts like a no-op wherever it is written to a file. Some background:
Martin Scharrer writes in some comment to another question:
A moving argument is an argument which is written into an auxiliary file (like
.aux, but also.tocand others) which is then read on some other position at the next run. Things like sectioning titles and labels are moving arguments.
This is an excellent explanation of the technical term "moving argument". Recall that macros can be "expanded" or "executed"; \protect prevents expansion. I want something converse, that doesn't prevent expansion but in fact deletes that instance of the macro entirely whenever it is being written to a file (i.e. wherever the argument is "moved").
There are two other questions that are related (but not identical):