I am trying to change the default directory using emacsclient, but it isn't working as I had hoped.

$ cd
$ emacsclient -e '(emacs-version)'
"GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.30, cairo version 1.15.10)\n of 2020-02-19"
$ emacsclient -e '(setq default-directory "/home/joe/system-test/auth/")'

M-x describe-variable RET default-directory RET

default-directory is a variable defined in ‘C source code’. Its value is "/home/joe/" Local in buffer shell; global value is nil

  • @Tobias, yep, this works for me. – Joe Corneli Feb 25 '20 at 18:51
  • 1
    Okay then we got the culprit and I convert my comment to an answer. (Questions answered in comments are a nuisance here on SE.) – Tobias Feb 25 '20 at 19:18

You did not say for which buffer you want to set the default directory.
If you want to do it for the (existing) shell buffer with name *shell* try the following shell command:

emacsclient -e '(with-current-buffer "*shell*" (setq default-directory "/home/joe/system-test/auth/"))`

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.