Search code examples
emacscommon-lispflushsbclslime

slime prints my (format ...) calls only when called function ends


I have emacs + sbcl + slime installed. I have this function defined

(defun jugar ()
  (let* ((nodoActual *nodo-inicial*)
         (estadoActual (nodo-estado nodoActual))
         (timeStart nil)
         (timeEnd nil)
         )
    (loop while (not (es-estado-final estadoActual)) do
          (setf *hojas* 0)
          (setf timeStart (get-universal-time))
          (setf nodoActual (decision-minimax nodoActual *profundidad* timeStart))
          (setf timeEnd (get-universal-time))
          (setf estadoActual (nodo-estado nodoActual))
          (imprime-en-fichero estadoActual)
          (format t "Hojas analizadas:     ~a  ~%" *hojas*)
          (format t "Tiempo empleado:     ~a  ~%~%" time))   
    ))

that makes a series of calls and print some variables in a loop.

The problem is when I call (jugar) from the *slime-repl sbcl* buffer, the prompt waits until (jugar) execution ends for showing all the (format …) together. I tried the same from a terminal (running sbcl) and it works well, so I guess it is something related to emacs or slime. How can I fix it?


Solution

  • Add (force-output) after last (format ) call.