Package: virtualenvwrapper-emacs-desktop
Emacsdesktop-modelets you save the state of emacs (open buffers,
kill rings, buffer positions, etc.) between sessions.  It can also be
used as a project file similar to other IDEs.  Thisvirtualenvwrapperplugin adds a trigger to save the current desktop file and load a new
one when activating a new virtualenv usingworkon.InstallationInstall this plugin with pip:$ pip install virtualenvwrapper-emacs-desktopOr by unpacking the source distribution and runningsetup.pydirectly:$ tar zxvf virtualenvwrapper-emacs-desktop-X.Y.tar.gz
$ cd virtualenvwrapper-emacs-desktop-X.Y
$ python setup.py installYou may need administrator privileges to install to a global location.Configuring Desktop Mode in EmacsSetup of desktop-mode is straightforward:Runcustomize-groupon the “desktop” group.Turndesktop-save-modeonto enable the minor mode.Optionally change the base name for desktop files indesktop-base-file-name. For example, using “emacs.desktop”
means the file will not be hidden.Set a default search path for the desktop file indesktop-path.
Use your home directory, or the directory where you keep your emacs
configuration files (~/emacs.dor~/emacs).  This value is
thedefault.  Your real desktop files will be saved into the
virtualenv directories.Setdesktop-savetoAlways save. There are other values
that work, but some require interaction with the editor during the
context move to confirm file saves.There are a few other options that may be useful to tweak, depending
on the other features of emacs you use. For example,desktop-clear-preserve-bufferslets you control which buffers are
saved when the desktop is cleared on a reload.  It may be useful to
save the*Messages*,*Org Agenda*, and*scratch*buffers,
since those are related to emacs operation and not limited to any one
project.VIRTUALENVWRAPPER_EMACSCLIENTIf theemacsclientbinary visible on your$PATHdoes not match
the version of emacs you are using, setVIRTUALENVWRAPPER_EMACSCLIENTto the full path of the version to
use instead.export VIRTUALENVWRAPPER_EMACSCLIENT=/Applications/Emacs.app/Contents/MacOS/bin/emacsclientEnabling the PluginSwitching desktop sessions every timeworkonis used would make it
impossible to have two shells open and working on separate projects at
the same time.  Therefore, the plugin must be explicitly enabled in
the shell where it should control the emacs session.Two shell functions (emacs_desktop_controller_onandemacs_desktop_controller_off) are provided to switch the plugin on
and off.  They do this by changing the variableDESKTOP_CONTROLLER, which the plugin examines before taking any
action.  If the variable is not set, or is defined but empty, the
plugin makes no changes.  If the variable is set to any value, the
session is changed.Most modern terminal programs make it easy to create custom
configurations with specific settings.  Use your terminal’s
customization feature to create a “desktop controller” configuration
withDESKTOP_CONTROLLERset, then control
virtualenvwrapper-emacs-desktop from a terminal using that
configuration.Terminal.appThe default OS X terminal emulator Terminal.app lets you set up
profiles with custom configurations, including running a command when
the new window is opened.  Create a new profile, then under theShelltab, set:Run command:emacs_desktop_controller_onRun inside shell:EnablediTermThe third-party OS X terminal emulatoriTermlets you set up
“bookmarks” with custom configurations, including the “Working Dir”.
One way to use this to control the plugin is to set up a special
bookmark with a working directory set to$WORKON_HOME, then add a
check to~/.bashrcto check for that condition.Name:emacs-controlCommand:bash-lWorking Dir:/Users/username/.virtualenvsTerminal:DefaultKeyboard:GlobalDisplay:Default~/.bashrc settings:if [ "$(pwd)" = "$WORKON_HOME" ]
then
    emacs_desktop_controller_on
else
    emacs_desktop_controller_off
fiemacs shellshell-mode in emacs setsEMACSandINSIDE_EMACS, so you can
test for those environment variables.Gnome Terminal?KDE?NoteIf you have suggested configuration mechanisms for other terminal
emulators or other platforms, please post them in the comments and I
will add them to this README file.ReferencesSaving Emacs SessionsDesktop Save Modedesktop-modevirtualenvwrapper