If I invoke emacsclient with emacsclient -na runemacs file1
emacsclients switch to the frame containing file1.
But if later I invoke emacs with emacsclient -na runemacs file2
emacsclient opens file2 in the existing frame of file1.
On the other hand emacsclient -cna runemacs file1
always creates a new frame regardless of if file1 is already opened or not.
I prefer that emacsclient creates a new frame of a file if that file is not already open in the existing frames, otherwise emacsclient switchs to the frame containing it.
I guess I should send some elisp code by -e
option to the emacsclient for checking this but I was not able to find the right code.
There is a related question Make emacsclient create a frame only if there isn't one already without an accepted answer. The upvoted answer there uses a bash script hence not a pure elisp solution.