From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: phillip.lord@russet.org.uk (Phillip Lord) Newsgroups: gmane.emacs.devel Subject: Adding streams for standard out and standard err Date: Wed, 20 Jul 2016 23:48:43 +0100 Message-ID: <87oa5sexis.fsf@russet.org.uk> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1469055024 9394 80.91.229.3 (20 Jul 2016 22:50:24 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 20 Jul 2016 22:50:24 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jul 21 00:50:14 2016 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 1bQ0Jh-0006XM-9K for ged-emacs-devel@m.gmane.org; Thu, 21 Jul 2016 00:50:13 +0200 Original-Received: from localhost ([::1]:37393 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQ0Jg-0002A2-EJ for ged-emacs-devel@m.gmane.org; Wed, 20 Jul 2016 18:50:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60948) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQ0J7-00029c-Mf for emacs-devel@gnu.org; Wed, 20 Jul 2016 18:49:38 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bQ0J3-0006uc-ET for emacs-devel@gnu.org; Wed, 20 Jul 2016 18:49:36 -0400 Original-Received: from cloud103.planethippo.com ([31.216.48.48]:48262) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQ0J3-0006cF-36 for emacs-devel@gnu.org; Wed, 20 Jul 2016 18:49:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=russet.org.uk; s=default; h=Content-Type:MIME-Version:Message-ID:Date: Subject:To:From; bh=wUsrPjXX2z1Y3e3LnYEBUG/HFDFoCc0yOswG+zFmObQ=; b=CpgcMOf9/ bp/5juX98yE+0MFcxbsaNL65qXmrzG50t8+aRdXHAEipmCPhIc7OMkxOXA7423opGOt9he5A4rrbI IeYB+RUZTCKrQuVvUdCGcjBdMVVV6cIwvKiJceed2AHF+PyPnpNDV8YxNBIOTOSCKker7J/fEBvH/ D2arGbciQcsZnKTqaS6LyjxBp/Fq4dCLdCuvg4/8liv/6tzVyjQIlXE51t3CtNZ45H4REFaTIvn/7 UXTh/nP1JOKdNhwzwdszN5q9TD8cRUQPYHlXw0J6+XmduvZam8QH8+Xhv/oqWCqFJ5+Nitt0h86V2 R2WDxxH+c9k/4Nu6ONdAQzuyg==; Original-Received: from cpc1-benw10-2-0-cust373.gate.cable.virginm.net ([77.98.219.118]:51437 helo=russet.org.uk) by cloud103.planethippo.com with esmtpsa (TLSv1.2:DHE-RSA-AES128-SHA:128) (Exim 4.86_1) (envelope-from ) id 1bQ0IN-0027rM-9m for emacs-devel@gnu.org; Wed, 20 Jul 2016 23:48:51 +0100 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.95 (gnu/linux) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - cloud103.planethippo.com X-AntiAbuse: Original Domain - gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - russet.org.uk X-Get-Message-Sender-Via: cloud103.planethippo.com: authenticated_id: phillip.lord@russet.org.uk X-Authenticated-Sender: cloud103.planethippo.com: phillip.lord@russet.org.uk X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 31.216.48.48 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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" Xref: news.gmane.org gmane.emacs.devel:205926 Archived-At: --=-=-= Content-Type: text/plain For a while I've wanted Emacs to have the ability to write to standard out, and/or standard err, when not running in batch. Mostly, I've wanted for debugging, as it involves touching no buffers at all. Comments welcome... --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Add-streams-for-stdout-stderr.patch >From eac3394997a122d57f90bea2ca850ac609104840 Mon Sep 17 00:00:00 2001 From: Phillip Lord Date: Mon, 18 Jul 2016 23:28:05 +0100 Subject: [PATCH] Add streams for stdout, stderr * src/print.c (Fstdout,Fstderr): New function --- doc/lispref/streams.texi | 21 +++++++++++++++++++++ src/print.c | 20 ++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/doc/lispref/streams.texi b/doc/lispref/streams.texi index 41bc71e..7d26c9f 100644 --- a/doc/lispref/streams.texi +++ b/doc/lispref/streams.texi @@ -530,6 +530,27 @@ Output Streams Calling @code{concat} converts the list to a string so you can see its contents more clearly. +Two functions which are specifically designed for use as output +streams: + +@table @asis +@cindex @code{stdout} output stream +@item @var{stdout} +Prints to the system standard output (as opposed to the +@var{standard-output}), regardless of whether Emacs is running +interactively or not. + +@item @var{stderr} output stream +Prints to the system standard error, regardless of whether Emacs is +running interactively or not. +@end table + +These functions are predominately useful for debugging, as they are a +mechanism for producing output that does not change any buffer. Note +that these functions do not flush their output; in general, no output +will be produced until a newline. + + @node Output Functions @section Output Functions diff --git a/src/print.c b/src/print.c index 5531210..f5a38c3 100644 --- a/src/print.c +++ b/src/print.c @@ -264,6 +264,24 @@ printchar_to_stream (unsigned int ch, FILE *stream) } } +DEFUN ("stdout", Fstdout, Sstdout, 1, 1, 0, + doc: /* Output character CHARACTER to system standard output. */) + (Lisp_Object character) +{ + CHECK_NUMBER (character); + printchar_to_stream (XINT(character), stdout); + return character; +} + +DEFUN ("stderr", Fstderr, Sstderr, 1, 1, 0, + doc: /* Output character CHARACTER to system standard error. */) + (Lisp_Object character) +{ + CHECK_NUMBER (character); + printchar_to_stream (XINT(character), stderr); + return character; +} + /* Print character CH using method FUN. FUN nil means print to print_buffer. FUN t means print to echo area or stdout if non-interactive. If FUN is neither nil nor t, call FUN with CH as @@ -2301,6 +2319,8 @@ priorities. */); /* prin1_to_string_buffer initialized in init_buffer_once in buffer.c */ staticpro (&Vprin1_to_string_buffer); + defsubr (&Sstdout); + defsubr (&Sstderr); defsubr (&Sprin1); defsubr (&Sprin1_to_string); defsubr (&Serror_message_string); -- 2.9.2 --=-=-=--