Search code examples
emacs

Emacs: how to unset environment variable?


I used setenv emacs-lisp to set an environment variable in my Emacs workspace(e.g. DEBUG_FOO=1).

How to unset/delete it completely? I prefer not to keep it even as a blank string


Solution

  • Turns out setenv man page explains it pretty well:

    Interactively, a prefix argument means to unset the variable, and otherwise the current value (if any) of the variable appears at the front of the history list when you type in the new value. This function always replaces environment variables in the new value when called interactively.

    So instead of the usual M-x call(SPC SPC in spacemacs), it hard to be done using prefix argument instead, in my case(in spacemacs) it is SPC u SPC SPC, then setenv and blank value will get it unset:

    setenv interactive screenshot