Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to run certain elisp code after starting a new emacsclient frame?

For how to automatically evaluate certain lisp code every time starting an emacsclient, click here.

My problem is different. I want to write a script that opens a new emacs frame (with focus on it) (one way to do this is to run emacsclient -c) and then run the following elisp code in that frame.

(org-remember)

I tried

emacsclient -c & emacsclient -eval '(org-remember)'

But sometimes it just opens a new frame unfocused and then runs the elisp code, and other times, it opens a new frame focused but runs the elisp code in the old frame.

Some who knows what org-remember does might ask me why not just do this:

emacsclient -eval '(org-remember)'

but that doesn't bring focus on the old frame.

like image 522
Yoo Avatar asked Dec 30 '09 15:12

Yoo


1 Answers

My version of emacsclient doesn't support the -c argument, despite the documentation advertising it.

I'm not sure if there's a cleaner way to do this, but you could try using make-frame and select-frame, like so:

emacsclient -e '(select-frame (make-frame))' '(org-remember)'

That will create a new frame and, in case your window manager doesn't select it automatically, grant it focus, and then execute the second command with that new frame having focus.

like image 144
seh Avatar answered Sep 29 '22 20:09

seh