[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 5/5] emacsclient: add extra-quiet mode
From: |
Spencer Baugh |
Subject: |
[PATCH 5/5] emacsclient: add extra-quiet mode |
Date: |
Mon, 6 Jun 2016 21:25:06 -0400 |
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
- Teaching emacsclient to act as a pager, and more, Spencer Baugh, 2016/06/06
- [PATCH 3/5] emacsclient: support passing stdin/out/err to emacs, Spencer Baugh, 2016/06/06
- [PATCH 4/5] server: add pager tapping and show-active, Spencer Baugh, 2016/06/06
- [PATCH 5/5] emacsclient: add extra-quiet mode,
Spencer Baugh <=
- [PATCH 1/5] process: add features for direct use of FDs, Spencer Baugh, 2016/06/06
- [PATCH 2/5] server.el: accept FDs from emacsclient, Spencer Baugh, 2016/06/06
- Re: Teaching emacsclient to act as a pager, and more, Tassilo Horn, 2016/06/08
- Re: Teaching emacsclient to act as a pager, and more, H. Dieter Wilhelm, 2016/06/09
- Re: Teaching emacsclient to act as a pager, and more, Ole JørgenBrønner, 2016/06/27