Sometimes the way emacs utterly ignores standard unix conventions can be pretty annoying. In particular the fact that, unlike almost every other standard unix tool, you can’t give it
- instead of a filename and have it read from stdin has always annoyed me (yes, I know emacs came from lisp machines not unix, but it’s been used on unix machines since before I was born). So today I’ve final sat down and figured out how to hack around this limitation.
First of all I should note that there is an existing package called
e-sink to read from stdin. However the code seems unnecessarily complex (probably doesn’t help that I don’t know perl).
So, here’s my solution:
If you prefer to use a standalone emacs just replace
emacsclient -c -n in
The function is called as
One more note: each time you read from stdin a temporary file in
/tmp is created, these are typically cleared on reboot which is good enough for me. If you need them to be gone immediately you could add
rm $tempfile inside the
As always the code is on github.