So I have a hack to get my emacs org-clock to display in polybar (a system panel utility). It involves a script that looks like this:

CLOCKSTRING=`emacsclient --eval "(if (org-clocking-p)(print (org-clock-get-clock-string))(print -1))))"`

if [[ $CLOCKSTRING = "-1" ]]
        echo "Off-clock!"
        echo $CLOCKSTRING | cut -d\" -f2

The problem is that print apparently prints to both the output of the commandline command (where I want it) and to a buffer in emacs (where I don't want it. When I'm working in emacs, I just see a window pop up that says the output of this command all the time, i.e. "-1 -1 -1 -1". How do I get print to print only to the command line?

  • 1
    Which window are you talking about? the Echo Area? And can you explain your issue with simpler code, such as emacsclient --eval '(message "hi")', does it has the same issue?
    – xuchunyang
    Oct 6, 2017 at 20:00
  • 1
    Probably just remove the calls to print.
    – politza
    Oct 6, 2017 at 21:51
  • Yep, changing print to message seemed to have done the trick.
    – Jonathan
    Oct 7, 2017 at 0:33
  • 1
    You don't need message either.
    – politza
    Oct 7, 2017 at 5:08

2 Answers 2


When Emacsclient evaluates an expression, it's evaluated in a “normal” Emacs context. Standard output goes to its normal destination, which is the echo area. It doesn't go to Emacsclient. What you see in Emacsclient is the return value. So drop the print.

CLOCKSTRING=`emacsclient --eval "(if (org-clocking-p) (org-clock-get-clock-string) -1)"`

Your problem might be that your S-expression is unbalanced (two extra parentheses at the end).

This emacsclient --eval '(if (org-clocking-p)(print (org-clock-get-clock-string))(print -1))' returns -1 on the command line for me.

  • Nope, this has no effect.
    – Jonathan
    Oct 7, 2017 at 0:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.