unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: peder@klingenberg.no (Peder O. Klingenberg)
To: Eli Zaretskii <eliz@gnu.org>
Cc: 25708@debbugs.gnu.org, alexhutcheson@google.com
Subject: bug#25708: 25.1.91; Allow users to inhibit printing for 'emacsclient -c -t'
Date: Mon, 20 Feb 2017 18:19:20 +0100	[thread overview]
Message-ID: <m160k4zso7.fsf@modesty> (raw)
In-Reply-To: <m18tp1z1a4.fsf@modesty> (Peder O. Klingenberg's message of "Mon,  20 Feb 2017 09:58:43 +0100")

[-- Attachment #1: Type: text/plain, Size: 162 bytes --]

peder@klingenberg.no (Peder O. Klingenberg) writes:

> Ok.  I'll take a stab at implementing that later today.

How about this patch instead of my previous one?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-New-option-u-quell-to-emacsclient.patch --]
[-- Type: text/x-patch, Size: 4999 bytes --]

From 6c6f60c200f8bb2ed873cdc8c8ac8e90e090d65f Mon Sep 17 00:00:00 2001
From: "Peder O. Klingenberg" <peder@klingenberg.no>
Date: Sun, 19 Feb 2017 20:59:14 +0100
Subject: [PATCH] New option -u / -quell to emacsclient

When evaluating expressions for side-effects with emacsclient, the
result returned from the server is often useless.  These new options
allow the user to skip the printing of non-error
results.  (Bug#25708)

* lib-src/emacsclient.c (print_help_and_exit, longopts)
(decode_options, main): Implement new option --quell / -u to suppress
printing of eval-results.
* doc/emacs/misc.texi (emacsclient Options): Document new
--quell / -u options.
---
 doc/emacs/misc.texi   |  6 ++++++
 etc/NEWS              |  4 ++++
 lib-src/emacsclient.c | 37 ++++++++++++++++++++++++++-----------
 3 files changed, 36 insertions(+), 11 deletions(-)

diff --git a/doc/emacs/misc.texi b/doc/emacs/misc.texi
index 091ead1bae..df4c1f717d 100644
--- a/doc/emacs/misc.texi
+++ b/doc/emacs/misc.texi
@@ -1847,6 +1847,12 @@ emacsclient Options
 Do not let @command{emacsclient} display messages about waiting for
 Emacs or connecting to remote server sockets.
 
+@item -u
+@itemx --quell
+Do not let @command{emacsclient} display results returned from the
+server.  Mostly useful in combination with @samp{-e} when the
+evaluation performed is for side-effect rather than result.
+
 @item -s @var{server-name}
 @itemx --socket-name=@var{server-name}
 Connect to the Emacs server named @var{server-name}.  The server name
diff --git a/etc/NEWS b/etc/NEWS
index 143e4655de..394c1e904c 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -321,6 +321,10 @@ substituted by a home directory by writing it as "/foo:/:/~/file".
 settings of 'scroll-margin' up to half the window size, instead of
 always restricting the margin to a quarter of the window.
 
++++
+** Emacsclient has a new option -u/--quell.  The option suppresses
+display of non-error return values from the server process.
+
 \f
 * Editing Changes in Emacs 26.1
 
diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c
index 70709ecec0..1bb772be1b 100644
--- a/lib-src/emacsclient.c
+++ b/lib-src/emacsclient.c
@@ -118,6 +118,9 @@ int nowait = 0;
 /* Nonzero means don't print messages for successful operations.  --quiet.  */
 int quiet = 0;
 
+/* Nonzero means don't print values returned from emacs. --quell */
+int quell = 0;
+
 /* Nonzero means args are expressions to be evaluated.  --eval.  */
 int eval = 0;
 
@@ -160,6 +163,7 @@ struct option longopts[] =
 {
   { "no-wait",	no_argument,	   NULL, 'n' },
   { "quiet",	no_argument,	   NULL, 'q' },
+  { "quell",	no_argument,	   NULL, 'u' },
   { "eval",	no_argument,	   NULL, 'e' },
   { "help",	no_argument,	   NULL, 'H' },
   { "version",	no_argument,	   NULL, 'V' },
@@ -469,9 +473,9 @@ decode_options (int argc, char **argv)
     {
       int opt = getopt_long_only (argc, argv,
 #ifndef NO_SOCKETS_IN_FILE_SYSTEM
-			     "VHneqa:s:f:d:F:tc",
+			     "VHnequa:s:f:d:F:tc",
 #else
-			     "VHneqa:f:d:F:tc",
+			     "VHnequa:f:d:F:tc",
 #endif
 			     longopts, 0);
 
@@ -519,6 +523,10 @@ decode_options (int argc, char **argv)
 	  quiet = 1;
 	  break;
 
+	case 'u':
+	  quell = 1;
+	  break;
+
 	case 'V':
 	  message (false, "emacsclient %s\n", VERSION);
 	  exit (EXIT_SUCCESS);
@@ -631,6 +639,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\
+-u, --quell		Don't display non-error return values from the server\n\
 -d DISPLAY, --display=DISPLAY\n\
 			Visit the file in the given display\n\
 ", "\
@@ -1860,19 +1869,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 (!quell)
+		{
+		  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 (!quell)
+		{
+		  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


[-- Attachment #3: Type: text/plain, Size: 16 bytes --]


--
...Peder...

  reply	other threads:[~2017-02-20 17:19 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-13 19:46 bug#25708: 25.1.91; Allow users to inhibit printing for 'emacsclient -c -t' Alex Hutcheson
2017-02-19 20:54 ` Peder O. Klingenberg
2017-02-20  3:29   ` Eli Zaretskii
2017-02-20  8:58     ` Peder O. Klingenberg
2017-02-20 17:19       ` Peder O. Klingenberg [this message]
2017-02-20 17:34         ` Eli Zaretskii
2017-02-20 18:28           ` Peder O. Klingenberg
2017-02-20 18:04         ` Andreas Schwab
2017-02-20 18:13           ` Eli Zaretskii
2017-02-20 19:15             ` Andreas Schwab
2017-02-20 20:55               ` Peder O. Klingenberg
2017-02-25  8:33                 ` Eli Zaretskii
2017-02-20 18:17           ` Peder O. Klingenberg

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=m160k4zso7.fsf@modesty \
    --to=peder@klingenberg.no \
    --cc=25708@debbugs.gnu.org \
    --cc=alexhutcheson@google.com \
    --cc=eliz@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).