Emacs Notes

1 eshell

1.1 Changing the timeout on sudo

By default in the eshell, you have to enter your password for sudo everytime I sudo something. This gets a bit annoying since I often have to run related sudo commands.

I found a way to change the time out at this discussion. Essentially, I first added these lines to my init.el file.

(require 'em-tramp) ; to load eshell’s sudo
(setq eshell-prefer-lisp-functions t)
(setq eshell-prefer-lisp-variables t)

Then, in the eshell, I created the following alias that gets permanently saved to my .emacs.d/ directory:

alias sudo 'eshell/sudo $*'

Finally, I added these lines to my init.el

(setq password-cache t) ; enable password caching
(setq password-cache-expiry 5) ; for five minutes

After reloading emacs, I found that the password can now be cached.

2 The Virtualenv package

2.1 Installation

To install this package, simply use emacs's package manager: M-x list-packages. The package to install is called ``virtualenv''. I installed version 1.2 from the Marmelade repo on 2015-02-10.

2.2 The default environments directory

This package treats ~/.virtualenvs as the default directory. It can probably be changed, but it was just easier for me to install my virtualenvs to this directory. (Don't forget to set the environment variable WORKON_HOME to this directory as well).

2.3 Switch virtual environments

Most emacs commands for this package start with ``virtualenv-''. For example, work on a specific environment, use virtualenv-workon. You can replace ``workon'' with ``deactivate'' to turn off a given virtual environment.

3 Useful keybindings

C-h b
List all keybindings
C-h f
Describe an emacs/elisp function