Emacsclient to get the current buffer?

When I use emacsclient --eval '(current-buffer)' , it returns *server* instead of current-buffer in emacs. I can insert and modify *server* using the --eval , but is there a way to find out if inserts into the current buffer do this? Is there a way to pass a string like #<buffer index.html> and turn it into a buffer object?

+4
source share
1 answer

Try (window-buffer (selected-window)) . For instance,

 emacsclient --eval '(with-current-buffer (window-buffer (selected-window)) (insert "foo"))' 
+9
source

All Articles