From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: ielm changes: display standard-output in buffer Date: Fri, 27 Sep 2013 20:46:43 -0400 Message-ID: References: <5244795A.2000009@dancol.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1380329219 23446 80.91.229.3 (28 Sep 2013 00:46:59 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 28 Sep 2013 00:46:59 +0000 (UTC) Cc: Emacs development discussions To: Daniel Colascione Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Sep 28 02:47:02 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VPigY-0000cH-4M for ged-emacs-devel@m.gmane.org; Sat, 28 Sep 2013 02:47:02 +0200 Original-Received: from localhost ([::1]:39098 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VPigX-0002f4-Pr for ged-emacs-devel@m.gmane.org; Fri, 27 Sep 2013 20:47:01 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45240) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VPigN-0002ek-SB for emacs-devel@gnu.org; Fri, 27 Sep 2013 20:46:59 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VPigG-0000dL-J9 for emacs-devel@gnu.org; Fri, 27 Sep 2013 20:46:51 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.182]:17030) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VPigG-0000dF-E7 for emacs-devel@gnu.org; Fri, 27 Sep 2013 20:46:44 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av4EABK/CFG4rw/I/2dsb2JhbABEvw4Xc4IfAQVWIxALDiYSFBgNJIgkwS2RCgOkeoFegxM X-IPAS-Result: Av4EABK/CFG4rw/I/2dsb2JhbABEvw4Xc4IfAQVWIxALDiYSFBgNJIgkwS2RCgOkeoFegxM X-IronPort-AV: E=Sophos;i="4.84,565,1355115600"; d="scan'208";a="29277668" Original-Received: from 184-175-15-200.dsl.teksavvy.com (HELO pastel.home) ([184.175.15.200]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 27 Sep 2013 20:43:39 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id 3AB65631A0; Fri, 27 Sep 2013 20:46:43 -0400 (EDT) In-Reply-To: <5244795A.2000009@dancol.org> (Daniel Colascione's message of "Thu, 26 Sep 2013 11:13:46 -0700") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.182 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:163695 Archived-At: > +(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 ) RET and then (princ ) RET and expect to be sent to any more. Maybe a buffer-local setting (instead of a let-binding) of standard-output would solve this problem? Stefan