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))'