Skip to content

Instantly share code, notes, and snippets.

@skeptomai
Created December 1, 2013 17:29
Show Gist options
  • Select an option

  • Save skeptomai/7737484 to your computer and use it in GitHub Desktop.

Select an option

Save skeptomai/7737484 to your computer and use it in GitHub Desktop.
Switch emacs working directory when file is loaded with emacsclient
(add-hook 'server-switch-hook
(lambda nil
(let ((server-buf (current-buffer)))
(setq default-directory "/tmp"))))
@skeptomai
Copy link
Author

This sets the buffer-local working directory. If you evaluate this, then open a file with emacsclient, then M-x eval-expression default-directory, you'll see the directory printed in the status line is what you expect and is not the same as the default-directory if you evaluate this from any other buffer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment