all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Daniel Colascione <dancol@dancol.org>
Cc: Emacs development discussions <emacs-devel@gnu.org>
Subject: Re: ielm changes: display standard-output in buffer
Date: Fri, 27 Sep 2013 20:46:43 -0400	[thread overview]
Message-ID: <jwvd2ntvl1k.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <5244795A.2000009@dancol.org> (Daniel Colascione's message of "Thu, 26 Sep 2013 11:13:46 -0700")

> +(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



  parent reply	other threads:[~2013-09-28  0:46 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-26 18:13 ielm changes: display standard-output in buffer Daniel Colascione
2013-09-26 20:49 ` Stefan Monnier
2013-09-27  3:37   ` Daniel Colascione
2013-09-28  0:46 ` Stefan Monnier [this message]
2013-10-03  6:23   ` Daniel Colascione
2013-10-03 13:50     ` Stefan Monnier
2013-10-05  1:42       ` Daniel Colascione
2013-10-05 13:45         ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvd2ntvl1k.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=dancol@dancol.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.