I use emacs on a lot of different types of machines during the day, so I'm toying with writing some elisp scripts to avoid managing 4 scripting environments.

Specifically, I'm writing an elisp function to convert the batch-agenda-csv output into a markdown blob. However, I don't seem to be understanding how the piping works. The command I'm using is here:

emacs -batch -eval '(org-batch-agenda-csv "a" org-agenda-files (quote ("~/org_life/work.org")) org-agenda-span (quote week) org-agenda-start-on-weekday 0)' | ftwynnfunc

in this case, the ftwynnfunc is simply:

(defun ftwynnfunc (text)
  (concat text "**"))

I would've expected the output from emacs to get piped to the function, which would append "**" and display on stdout. Instead, I get a usage statement from ftwynnfunc and the csv output displays afterward. Am I missing something about how pipelines work in eshell (or possibly something even more basic)?

  • Are you running the emacs -batch ... command from an active eshell buffer? That's not necessary - you should be able to run elisp code from eshell without starting a whole new emacs process
    – Tyler
    Jul 25 '19 at 15:16
  • I am, and I tried that, but running org-batch-agenda-csv seems to route the output to an agenda buffer rather than to stdout
    – FTWynn
    Jul 25 '19 at 23:34

AFAIK piping in Eshell works on the stdin side only for external commands.

You can send stuff through eshell/echo into a pipe but you cannot read from stdin via (read) in a non-batch emacs session. If you try you get an unwanted interactive prompt.

(I would be happy if somebody could prove me wrong in that regard.)

That being said, what you actually want to do is to use the output of a command as argument for a lisp function.

You can do that with the dollar expansion ${...}.


format "foo(%s)" ${*emacs --batch --eval "(prin1 'bar)"}



I did not try org-batch-agenda-csv here because I believe that Eshell is overkill for that. You should do that in Elisp only.

  • Routing it through eshell/echo is a good idea, but I seem to have the same problem that's particular to org-batch-agenda-csv where it displays in an agenda buffer instead of going through the pipe like it should.
    – FTWynn
    Aug 3 '19 at 22:04

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.