unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Spencer Baugh <sbaugh@catern.com>
To: emacs-devel@gnu.org
Cc: Spencer Baugh <sbaugh@catern.com>
Subject: [PATCH 5/5] emacsclient: add extra-quiet mode
Date: Mon,  6 Jun 2016 21:25:06 -0400	[thread overview]
Message-ID: <1465262706-5229-6-git-send-email-sbaugh@catern.com> (raw)
In-Reply-To: <1465262706-5229-1-git-send-email-sbaugh@catern.com>

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




  parent reply	other threads:[~2016-06-07  1:25 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-07  1:25 Teaching emacsclient to act as a pager, and more Spencer Baugh
2016-06-07  1:25 ` [PATCH 1/5] process: add features for direct use of FDs Spencer Baugh
2016-06-07  1:25 ` [PATCH 2/5] server.el: accept FDs from emacsclient Spencer Baugh
2016-06-07  1:25 ` [PATCH 3/5] emacsclient: support passing stdin/out/err to emacs Spencer Baugh
2016-06-07  1:25 ` [PATCH 4/5] server: add pager tapping and show-active Spencer Baugh
2016-06-07  1:25 ` Spencer Baugh [this message]
2016-06-08 15:51 ` Teaching emacsclient to act as a pager, and more Tassilo Horn
2016-06-08 16:13   ` Anders Lindgren
2016-06-08 17:30     ` Tassilo Horn
2016-06-09  0:25   ` raman
2016-06-09 11:31 ` H. Dieter Wilhelm
2016-06-27 22:42 ` Ole JørgenBrønner
2016-07-24 18:22 ` sbaugh
2016-09-09 13:42   ` Noam Postavsky
2016-09-09 14:14     ` sbaugh
2016-09-09 14:59       ` Stefan Monnier
2016-09-09 15:58         ` sbaugh
2016-09-09 19:26           ` Stefan Monnier
2016-09-09 19:42             ` Eli Zaretskii
2016-09-09 21:13             ` sbaugh
2016-09-10  6:37               ` Using file descriptors in Emacs (was: Teaching emacsclient to act as a pager, and more) Eli Zaretskii
2016-09-10 20:15             ` Teaching emacsclient to act as a pager, and more sbaugh
2016-09-11  2:11               ` Leo Liu
2018-02-16 23:14               ` Kaushal Modi
2018-02-17 15:46                 ` Göktuğ Kayaalp
2016-09-09 15:53       ` Eli Zaretskii
2016-09-09 17:16         ` sbaugh
2016-09-09 18:50           ` Eli Zaretskii
2016-09-09 19:03             ` sbaugh
2016-09-09 19:26               ` Eli Zaretskii
2016-09-09 20:38                 ` sbaugh
2016-09-10  7:12                   ` Using file descriptors in Emacs Eli Zaretskii
2016-09-10 14:28                     ` sbaugh
2016-09-11 15:28                       ` Eli Zaretskii
2016-09-11 16:00                         ` sbaugh
2016-09-11 16:39                           ` Eli Zaretskii
2016-09-11 16:57                             ` sbaugh
2016-09-11 17:13                               ` Eli Zaretskii
2016-09-12 15:40                               ` Davis Herring
2016-09-09 13:27 ` Teaching emacsclient to act as a pager, and more sbaugh

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=1465262706-5229-6-git-send-email-sbaugh@catern.com \
    --to=sbaugh@catern.com \
    --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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).