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](https://tex.stackexchange.com/questions/47259/why-use-declaretextfontcommand-vs-just-newcommand#comment97245_47259):

> 
> A *moving argument* is an argument which is written into an auxiliary
>  file (like `.aux`, but also `.toc` and 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):

* [Macro to be used in a \section command that has no effect in the table of contents](https://tex.stackexchange.com/q/99473/14996)
* [Is there a way of defining a command which is automatically converted to a no-op after its first execution?](https://tex.stackexchange.com/q/99502/14996)