From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Spencer Baugh Newsgroups: gmane.emacs.devel Subject: [PATCH 5/5] emacsclient: add extra-quiet mode Date: Mon, 6 Jun 2016 21:25:06 -0400 Message-ID: <1465262706-5229-6-git-send-email-sbaugh@catern.com> References: <1465262706-5229-1-git-send-email-sbaugh@catern.com> NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1465262763 12537 80.91.229.3 (7 Jun 2016 01:26:03 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 7 Jun 2016 01:26:03 +0000 (UTC) Cc: Spencer Baugh To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Jun 07 03:25:56 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 1bA5mE-00030y-SU for ged-emacs-devel@m.gmane.org; Tue, 07 Jun 2016 03:25:55 +0200 Original-Received: from localhost ([::1]:46340 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bA5mD-0005bs-Fk for ged-emacs-devel@m.gmane.org; Mon, 06 Jun 2016 21:25:53 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51506) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bA5m5-0005Zg-46 for emacs-devel@gnu.org; Mon, 06 Jun 2016 21:25:46 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bA5ly-00023T-Vx for emacs-devel@gnu.org; Mon, 06 Jun 2016 21:25:44 -0400 Original-Received: from catern.com ([104.131.201.120]:38421 helo=mail.catern.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bA5ly-00023E-QI for emacs-devel@gnu.org; Mon, 06 Jun 2016 21:25:38 -0400 Original-Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.catern.com (Postfix) with ESMTPSA id B31C44F564; Tue, 7 Jun 2016 01:25:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=catern.com; s=default; t=1465262734; bh=B39A6sQzkFN4yTEzc2FMvh63aViPq+UITzXJlduhiVo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=gHEQ606FTZ1Zp6MHsM8W4uo8EMvMVjlhFRT9sU1zm49wP1Utu7DNQauyz9SoMYSqT AEOeSTqDiqLkZDZ6/hR9k4DEDN5/J8BOfFwDYVL79TqcMr1Vnka2E/oAOlpfvMimwv 0NO0g08+j+iqcO6lS4/kvmQKiDmNDhOwXr78jmwo= In-Reply-To: <1465262706-5229-1-git-send-email-sbaugh@catern.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 104.131.201.120 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:204216 Archived-At: For emacsclient to write any output at all while acting as a pipeline can be very disruptive. As a quick hack, passing -qq or -l will now silence absolutely all output from emacsclient. Eventually we should probably just write to /dev/tty instead of to stdout, since POSIX 10.1 says about /dev/tty: It is useful for programs or shell procedures that wish to be sure of writing messages to or reading data from the terminal no matter how output has been redirected. --- lib-src/emacsclient.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c index 1b1f75a..e1f35cb 100644 --- a/lib-src/emacsclient.c +++ b/lib-src/emacsclient.c @@ -436,6 +436,7 @@ static void message (bool, const char *, ...) ATTRIBUTE_FORMAT_PRINTF (2, 3); static void message (bool is_error, const char *format, ...) { + if (quiet > 1) return; va_list args; va_start (args, format); @@ -503,6 +504,7 @@ decode_options (int argc, char **argv) case 'l': pipeline = 1; + quiet = 2; send_fds_once = 1; break; #endif @@ -528,7 +530,7 @@ decode_options (int argc, char **argv) break; case 'q': - quiet = 1; + quiet++; break; case 'V': @@ -643,6 +645,7 @@ The following OPTIONS are accepted:\n\ -e, --eval Evaluate the FILE arguments as ELisp expressions\n\ -n, --no-wait Don't wait for the server to return\n\ -q, --quiet Don't display messages on success\n\ + Pass twice to suppress absolutely all output\n\ -d DISPLAY, --display=DISPLAY\n\ Visit the file in the given display\n\ ", "\ @@ -1542,7 +1545,8 @@ start_daemon_and_retry_set_socket (void) } else if (dpid < 0) { - fprintf (stderr, "Error: Cannot fork!\n"); + if (quiet <= 1) + fprintf (stderr, "Error: Cannot fork!\n"); exit (EXIT_FAILURE); } else @@ -1899,6 +1903,7 @@ main (int argc, char **argv) } else if (strprefix ("-print ", p)) { + if (quiet > 1) continue; /* -print STRING: Print STRING on the terminal. */ str = unquote_argument (p + strlen ("-print ")); if (needlf) @@ -1908,6 +1913,7 @@ main (int argc, char **argv) } else if (strprefix ("-print-nonl ", p)) { + if (quiet > 1) continue; /* -print-nonl STRING: Print STRING on the terminal. Used to continue a preceding -print command. */ str = unquote_argument (p + strlen ("-print-nonl ")); @@ -1916,6 +1922,7 @@ main (int argc, char **argv) } else if (strprefix ("-error ", p)) { + if (quiet > 1) continue; /* -error DESCRIPTION: Signal an error on the terminal. */ str = unquote_argument (p + strlen ("-error ")); if (needlf) @@ -1947,7 +1954,8 @@ main (int argc, char **argv) if (needlf) printf ("\n"); - fflush (stdout); + if (quiet <= 1) + fflush (stdout); while (fdatasync (1) != 0 && errno == EINTR) continue; -- 2.8.2