emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ielm changes: display standard-output in buffer


From: Stefan Monnier
Subject: Re: ielm changes: display standard-output in buffer
Date: Fri, 27 Sep 2013 20:46:43 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

> +(defun ielm-standard-output-impl (char)
> +  "`standard-output' while evaluating in ielm."
> +  (push char ielm-output-buffer)
> +  (when (eq char ?\n)
> +    (comint-output-filter
> +     ielm-active-process
> +     (apply #'string (nreverse ielm-output-buffer)))
> +    (setf ielm-output-buffer nil)))

You could avoid the two global vars with:

   (defun ielm-standard-output-impl (proc)
     "`standard-output' while evaluating in ielm."
     (let ((buffer nil))
       (lambda (char)
         (push char buffer)
         (when (eq char ?\n)
           (comint-output-filter proc (apply #'string (nreverse buffer)))
           (setf buffer nil)))))

> +                    (ielm-active-process (ielm-process))
> +                    (ielm-output-buffer nil)
> +                    (standard-output #'ielm-standard-output-impl)

And here do (standard-output (ielm-standard-output-impl (ielm-process)))

I do have one objection to the patch, tho: it resets standard-output
after each IELM command, so you can't use (setq standard-output <foo>) RET
and then (princ <bar>) RET and expect <bar> to be sent to <foo> any more.

Maybe a buffer-local setting (instead of a let-binding) of
standard-output would solve this problem?


        Stefan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]