rougier / nano-emacs

GNU Emacs / N Λ N O - Emacs made simple
GNU General Public License v3.0
2.52k stars 195 forks source link

example of how to get the split terminals working with each other #34

Closed zcaudate closed 3 years ago

zcaudate commented 3 years ago

I'd like to have something similar to the split setup that was shown in your reddit post.

Is there a way to have one terminal that has just a fixed treemacs directory setup and another as the target of the clicks? And how might one go about setting this up?

rougier commented 3 years ago

You need two instances of emacs (one in each pane) and one being a server (let's say the right one). When you click on something on the left pane, you have to bind a key such as to execute a command in the right one. For that, you just have to issue a emacsclient -e "some command". For example, emacsclient -e "find-file \"some-file.txt\""

zcaudate commented 3 years ago

is there an example of this anywhere? how does the left pane know that it's sending a message to the right one?

rougier commented 3 years ago

Not yet implemented. But the server is listening to requests from anywhere. If you open an emacs and start the server (server-start), then you can type on a terminal emacsclient -e "find-file \"some-file.txt\"" and your emacs will open the file as if you've typed the command inside emacs.

zcaudate commented 3 years ago

I tried it out. It works but I think when there's 2 windows, it alternates.

so say there are 3 windows open - 2 for documents, and one a navigation window, how would they all talk to each other so that goes to the first document window and goes to the second one but the navigation bar stays the same?

rougier commented 3 years ago

If the emacs server has two windows openend, I imagine an emacsclient command will open a file in the active window. If you want a different behavior, you would need to issue a command that tells emacs where to open the file.

zcaudate commented 3 years ago

Okay I see. Thanks.