I've recently started using Emacs octave-mode and discovered that when using printf Emacs seems to block and I have to kill the execution of an Octave script with C-g.

I can reproduce that problem by having a file testprintf.m with just that single following line:


or, alternatively, more authentical:

printf("Test: %d", 10);

Then, I execute this file with C-c C-i a (or, if you like, just that line with C-c C-i l) and I am seeing the mouse pointer turning into the waiting symbol signalling me that this Emacs command seems to hang. C-g terminates the command and allows further editing of the buffer. The Inferior Octave buffer does not show any output during and after this action.

Converting printf into a disp statement works but I'd like to make use of the convenient C-style formatting, Octave offers. Also, the same printf command works when directly copied into the Inferior Octave buffer with the expected out. I am using GNU Emacs 26.3 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.11) and Octave 4.4.1. I have also tried it without my ~/.emacs with the same result, the mouse pointer turning into the waiting symbol.

  • You don't say what actions you take to make Emacs hang. You just show some text. The question seems unclear, so far.
    – Drew
    May 10, 2020 at 15:33
  • Thanks, alright, I added some details in the hope this make my issue clearer.
    – mfg
    May 10, 2020 at 15:52

1 Answer 1


I can reproduce this, but I think it's a buffering issue: try


instead. Without the newline, accept-process-output seems to wait indefinitely.

Re: the comment from the OP - it should be fine to have multiple printf's without newlines, as long as there is a printf with a newline that is at the end of the code and is evaluated as part of that code - you just won't be able to evaluate things line by line. [LATER CORRECTION] But now that I have tried it, I see that it does not work: every printf has to have a newline, else accept-process-output waits indefinitely.

  • 1
    Thanks @NickD, indeed, adding a newline helps, e.g. printf("Test: %d\n", 10);. Sadly, newline's are what I frequently want to avoid to compose print output from different parts of the code in one line. Certainly, one can store output in variables, compose all into one call to printf with trailing \n. Still, a somewhat odd behaviour.
    – mfg
    May 11, 2020 at 8:34

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.