[Openmcl-devel] *echo-expression-to-listener*

Ron Garret ron at flownet.com
Mon Sep 4 12:28:54 PDT 2017

On Sep 4, 2017, at 12:20 PM, Ron Garret <ron at flownet.com> wrote:

> I just filed this ticket:
> https://trac.clozure.com/ccl/ticket/1420
> Some time between version 1.10 and 1.11 the *echo-expression-to-listener* functionality of the "Editor Execute Expression" Hemlock command stopped working. This seems to be because writing to (HEMLOCK-EXT:TOP-LISTENER-OUTPUT-STREAM) inside the context of a Hemlock command is no longer working.
> I started looking through the commit log (hooray git!) and found this:
> commit 70dac57d412f3952771a42884511ce9ae32d1006
> Author: Bill St. Clair <wws at clozure.com>
> Date:   Tue Sep 1 15:31:53 2015 +0000
>    Radically speed up IDE listener output and make it interruptible.
>    The IDE listener output is now double-buffered. Printing threads fill
>    one buffer, and the GUI thread empties the other.
>    To avoid me having to hurt my brain preventing deadlock, output from
>    the GUI thread to an IDE listener is dropped on the floor; you'll
>    never see it. Since it's unusual to output from the GUI thread to an
>    IDE listener (the default is the AltConsole, or, if you started CCL
>    from a command-line shell, that shell), this shouldn't be a practical
>    problem.
>    Fixes #1307.
> Which is awesome because 1307 was also driving me nuts, but I think this may have broken *echo-expression-to-listener*.
> Is there no way to have our cake and eat it too?

Hm, this seems to do the trick, though it seems rather hacky:

(defcommand "Editor Execute Expression" (p)
  "Executes the current region in the editor Lisp. Ensures the result is visible."
  (declare (ignore p))
  (let* ((region (copy-region (current-form-region)))
         (form (when *echo-expression-to-listener* (region-to-string region)))
         (doc (gui::top-listener-document))
         (buf (when doc (gui::hemlock-buffer doc))))
    (when buf
      (let ((HI::*CURRENT-BUFFER* buf))
        (move-mark (current-point) (region-end (buffer-region buf)))))
    (when form
        (ccl:process-run-function "foo" #'format s "~A~&" form)))
    (eval-region region)))

More information about the Openmcl-devel mailing list