Subject: Re: bug#25708: 25.1.91; Allow users to inhibit printing for 'emacsclient -c -t'

From: [email-masked] (Peder O. Klingenberg)
Date: Sun, 19 Feb 2017 21:54:22 +0100

Alex Hutcheson <[email-masked]> writes:

> It would be great if emacsclient had a way to inhibit printing the
> result, for cases where the user is only eval'ing the expressions for
> their side effects.

Emacsclient claims to have that functionality already.  From the
usage-message:

-q, --quiet		Don't display messages on success

This should, in my opinion, cover the case of successfully eval-ing
forms.  However, -q currently has no effect on output from emacs, it
only inhibits messages about connecting to emacs.

The attached patch should prevent emacsclient from printing non-error
output from emacs to the terminal.

With this the terminal stays quiet after exiting the client frame when I
do "emacsclient -q -c -e '(+ 2 3)'".  Without the -q, the terminal
prints 5 as before.

>From 6d3e185a9ddacd94b8950775e3fb056c568fc66d Mon Sep 17 00:00:00 2001
From: "Peder O. Klingenberg" <[email-masked]>
Date: Sun, 19 Feb 2017 20:59:14 +0100
Subject: [PATCH] Extend emacsclient --quiet to cover eval output

* lib-src/emacsclient.c (main): Extend --quiet flag to suppress
printing of eval-results. (Bug#25708)
---
 lib-src/emacsclient.c | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c
index 70709ecec0..65ea5541b8 100644
--- a/lib-src/emacsclient.c
+++ b/lib-src/emacsclient.c
@@ -1860,19 +1860,25 @@ main (int argc, char **argv)
           else if (strprefix ("-print ", p))
             {
               /* -print STRING: Print STRING on the terminal. */
-              str = unquote_argument (p + strlen ("-print "));
-              if (needlf)
-                printf ("\n");
-              printf ("%s", str);
-              needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n';
-            }
+	      if (!quiet)
+		{
+		  str = unquote_argument (p + strlen ("-print "));
+		  if (needlf)
+		    printf ("\n");
+		  printf ("%s", str);
+		  needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n';
+		}
+	    }
           else if (strprefix ("-print-nonl ", p))
             {
               /* -print-nonl STRING: Print STRING on the terminal.
                  Used to continue a preceding -print command.  */
-              str = unquote_argument (p + strlen ("-print-nonl "));
-              printf ("%s", str);
-              needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n';
+	      if (!quiet)
+		{
+		  str = unquote_argument (p + strlen ("-print-nonl "));
+		  printf ("%s", str);
+		  needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n';
+		}
             }
           else if (strprefix ("-error ", p))
             {
-- 
2.11.0