# How to globally disable and re-enable Echo?

I have Echo's buried in code all over my notebook, I'd like a flag to turn them all on or off globally.

• Sure Unprotect[Echo];Echo=Identity would disable them, but then you can't re-enable them
• A solution that works for all the various types of Echos (EchoName, EchoEvaluation, ...) would be nice
• QuietEcho doesn't work because I'd have to write it add it around every blob of code
• with Echo=., no? – Roma Lee Jan 13 at 18:32
• sure, but how do reenable it without restarting the kernel – M.R. Jan 13 at 18:34
• Also, you might use Echo = #& instead, since Echo can take multiple arguments. – Carl Woll Jan 13 at 18:42
• I would advocate for a global search-and-replace of all Echo[ with myEcho in your code, then at the top assign an appropriate value to myEcho, i.e. myEcho = Echo vs. myEcho = Identity depending on what you want. The global search should be relatively safe and painless, since Echo is not a common keyword in other function names. This would also work with all other types of Echo, turning them into myEcho... versions if you wanted. – MarcoB Jan 13 at 18:45
• @RomaLee This is likely due to Echo being one of the autoloaded symbols. Check, e.g. on a fresh kernel, this: OwnValues[Echo], you will see something like {HoldPattern[Echo] :> SystemDumpAutoLoad[Hold[Echo], Hold[Echo, EchoFunction], "LanguageEcho"] /; SystemDumpTestLoad}. So, initially, Echo has OwnValues. When you execute Echo[0] (actually, just Echo is enough), you cause that definition to run. As a result, OwnValues[Echo] get cleared, instead DownValues[Echo] get populated. When you do Echo = Identity without auto-load, you hopelessly overwrite autoload code. – Leonid Shifrin Jan 13 at 19:04

Echo has an autoload, so you need to make sure the symbol is autoloaded before you modify its values:

DisableEcho[] := (Unprotect[Echo]; Echo; Echo = #&; Protect[Echo];)

EnableEcho[] := (Unprotect[Echo]; Echo=.; Protect[Echo];)


Test:

DisableEcho[]

Echo[3]

EnableEcho[]

Echo[3, "EchoLabel"]


3

EchoLabel 3

3

• Ah, I forgot the autoload – M.R. Jan 13 at 19:22