I'd like to run calc in an emacsclient in my terminal, and then have that particular emacsclient session close completely and return me to my shell when calc quits.

I've got the first part of that working with emacsclient -t --eval '(calc nil t)' but when I quit calc, the emacsclient session stays open and just displays another buffer.

I've also tried emacsclient -t --eval '(calc nil t)(delete frame)' but that behaves no differently.

Then I tried emacsclient -t --eval '(progn (calc nil t)(delete frame))' but though that does exit emacsclient, it does so too soon, before I've even had a chance to use calc.

How can I make emacs close that emacsclient session only after I use and deliberately quit calc?

Update: I wound up Marco Wahl's solution below, but I modified it slightly to delete the hook when it's called, because I only wanted the frame deleted when calc is called from the shell through emacsclient, but not when it's called at other times from inside emacs itself.

So now I do: emacsclient -t -e '(progn (add-hook (quote calc-end-hook) (lambda () (setq calc-end-hook nil) (delete-frame)))(calc nil t))'

  • 1
    The reason it behaves the way it does is because (calc nil t) doesn't block the execution of Emacs Lisp interpreter. Interpreter thus will start Calc and then kill the frame containing it. I don't see a way to solve this problem the way you intended, but if you created an interactive command that deletes a frame and added a keybinding for that command to Calc's keymap, you could use it to quit Calc closing the session at the same time.
    – wvxvw
    Oct 8, 2017 at 12:51

2 Answers 2


You could use hook calc-end-hook to hook delete-frame.

emacsclient -t --eval '(progn (add-hook (quote calc-end-hook) (lambda () (delete-frame))) (calc nil t))'

You could quit calc using C-x 5 0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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