I'd like to send some commands to the terminal Emacs is running in, using send-string-to-terminal. However, some terminals don't support the command I have in mind.

When this is the case, the command is echoed after the cursor, temporarily overwriting the display, and causing graphical corruption:

Result of running M-:(send-string-to-terminal "\e[5 q") in xfce4-terminal

enter image description here

(Note that the text appears in the echo area by mere coincidence—if I had run the code using a keybinding in a different buffer, the output would be positioned after the cursor)

Obviously, this is not desirable. Is there a way to hide the output (or mask it by redrawing the display in that region) so the command can silently fail?

  • 1
    Try (redisplay t) or (force-window-update).
    – Dan
    Jan 22, 2016 at 23:41
  • 1
    Try (message) or (message "") to clear the echo area.
    – wasamasa
    Jan 23, 2016 at 10:00

1 Answer 1


You may temporarily replace the message function, which does the actual job of displaying the string in the echo area :

(cl-letf (((symbol-function 'message) #'ignore))
  (send-string-to-terminal "\e[5 q"))

ignore takes an arbitrary number of arguments, does nothing and returns nil.


I misunderstood the question's meaning. It turns out, after looking a bit at the send-string-to-terminal function definition in Emacs' C source, there is no way to prevent it from echoing the supplied command.

  • Unfortunately, this doesn't help. message isn't actually used in send-string-to-terminal, so there's no effect. Furthermore, the output doesn't always occur in the minibuffer. As I stated, it occurs after the cursor. It's placement in the minibuffer is merely a side-effect of my using the minibuffer to call the code.
    – PythonNut
    Dec 23, 2015 at 21:33
  • Oops :) I updated my answer with relevant info.
    – ngqrl
    Dec 23, 2015 at 22:19
  • Sorry about that, I'll add some more info to the question so nobody else gets confused.
    – PythonNut
    Dec 23, 2015 at 22:39

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.