I want to access contents of emacs buffers from outside like in acme editor.

Acme is in part a file server that exports device-like files that may be manipulated to access and control the contents of its windows.

And no I don't want plugin that makes emac behave like acme etc. I just want to be able to access and control the contents of buffers.

How can I do that? Is it possible?

  • 1
    Try using the daemon and emacsclient. – wasamasa Jan 17 '18 at 6:32
  • @wasamasa The daemon is not required for the objectives of the question even if it is related to the topic. – Tobias Jan 17 '18 at 10:18
  • Not posting this as an answer, as the current implementation is experimental, but here is a project, that among its goals, aims to expose emacs buffers as files, in a sort-of-plan9 way, via FUSE. – aplaice Jan 17 '18 at 12:32
  • Useful question. – Drew Jan 17 '18 at 14:21

It is possible to read and write the contents of a buffer with the combination of an emacs server and an emacsclient. (If you want you can run the server as daemon.)


  • Start emacs.
  • M-x server-start RET starts the server. Before you start the server you can set the name through the option server-name.
  • Create a buffer with known name, e.g. by C-x b mybuf RET (this could also be done with emacsclient)
  • Write some text in the buffer, e.g., some text
  • As a small example how to read buffer contents open a xterm and run there:

    emacsclient --server-file server --eval "(with-current-buffer \"mybuf\" (prin1 (buffer-string)))"
  • As a small example how to insert stuff into the buffer run in the same xterm:

    emacsclient --server-file server --eval "(with-current-buffer \"mybuf\" (insert \"\\nHello from the outside world.\"))"


  • Depending on your system and your emacs configuration it may be that you need to substitute --server-file by --socket-name in the call of emacsclient.

  • If you use the standard server name server you don't need the option --server-file server (or --socket-name server).

| improve this answer | |

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.