5

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 '17 at 12:51
5

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

You could quit calc using C-x 5 0

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.