aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src
diff options
context:
space:
mode:
authorPeder O. Klingenberg2017-02-25 10:30:46 +0200
committerEli Zaretskii2017-02-25 10:30:46 +0200
commitecbd5f9ac6eb2d31241657bbb3e3f9b860391054 (patch)
tree84bad9cbbedefea523038feea6cd703631ff828e /lib-src
parentf0e7f39e0b4026a3d613416ad8ffc84e6b74242b (diff)
downloademacs-ecbd5f9ac6eb2d31241657bbb3e3f9b860391054.tar.gz
emacs-ecbd5f9ac6eb2d31241657bbb3e3f9b860391054.zip
New option -u / --suppress-output to emacsclient
* lib-src/emacsclient.c (print_help_and_exit, longopts) (decode_options, main): Implement new option --suppress-output / -u to suppress printing of eval-results. * doc/emacs/misc.texi (emacsclient Options): Document the new "--suppress-output/-u" options. * etc/NEWS: Mention the new options.
Diffstat (limited to 'lib-src')
-rw-r--r--lib-src/emacsclient.c37
1 files changed, 26 insertions, 11 deletions
diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c
index 70709ecec04..7b735dfb05d 100644
--- a/lib-src/emacsclient.c
+++ b/lib-src/emacsclient.c
@@ -118,6 +118,9 @@ int nowait = 0;
118/* Nonzero means don't print messages for successful operations. --quiet. */ 118/* Nonzero means don't print messages for successful operations. --quiet. */
119int quiet = 0; 119int quiet = 0;
120 120
121/* Nonzero means don't print values returned from emacs. --suppress-output. */
122int suppress_output = 0;
123
121/* Nonzero means args are expressions to be evaluated. --eval. */ 124/* Nonzero means args are expressions to be evaluated. --eval. */
122int eval = 0; 125int eval = 0;
123 126
@@ -160,6 +163,7 @@ struct option longopts[] =
160{ 163{
161 { "no-wait", no_argument, NULL, 'n' }, 164 { "no-wait", no_argument, NULL, 'n' },
162 { "quiet", no_argument, NULL, 'q' }, 165 { "quiet", no_argument, NULL, 'q' },
166 { "suppress-output", no_argument, NULL, 'u' },
163 { "eval", no_argument, NULL, 'e' }, 167 { "eval", no_argument, NULL, 'e' },
164 { "help", no_argument, NULL, 'H' }, 168 { "help", no_argument, NULL, 'H' },
165 { "version", no_argument, NULL, 'V' }, 169 { "version", no_argument, NULL, 'V' },
@@ -469,9 +473,9 @@ decode_options (int argc, char **argv)
469 { 473 {
470 int opt = getopt_long_only (argc, argv, 474 int opt = getopt_long_only (argc, argv,
471#ifndef NO_SOCKETS_IN_FILE_SYSTEM 475#ifndef NO_SOCKETS_IN_FILE_SYSTEM
472 "VHneqa:s:f:d:F:tc", 476 "VHnequa:s:f:d:F:tc",
473#else 477#else
474 "VHneqa:f:d:F:tc", 478 "VHnequa:f:d:F:tc",
475#endif 479#endif
476 longopts, 0); 480 longopts, 0);
477 481
@@ -519,6 +523,10 @@ decode_options (int argc, char **argv)
519 quiet = 1; 523 quiet = 1;
520 break; 524 break;
521 525
526 case 'u':
527 suppress_output = 1;
528 break;
529
522 case 'V': 530 case 'V':
523 message (false, "emacsclient %s\n", VERSION); 531 message (false, "emacsclient %s\n", VERSION);
524 exit (EXIT_SUCCESS); 532 exit (EXIT_SUCCESS);
@@ -631,6 +639,7 @@ The following OPTIONS are accepted:\n\
631-e, --eval Evaluate the FILE arguments as ELisp expressions\n\ 639-e, --eval Evaluate the FILE arguments as ELisp expressions\n\
632-n, --no-wait Don't wait for the server to return\n\ 640-n, --no-wait Don't wait for the server to return\n\
633-q, --quiet Don't display messages on success\n\ 641-q, --quiet Don't display messages on success\n\
642-u, --suppress-output Don't display return values from the server\n\
634-d DISPLAY, --display=DISPLAY\n\ 643-d DISPLAY, --display=DISPLAY\n\
635 Visit the file in the given display\n\ 644 Visit the file in the given display\n\
636", "\ 645", "\
@@ -1860,19 +1869,25 @@ main (int argc, char **argv)
1860 else if (strprefix ("-print ", p)) 1869 else if (strprefix ("-print ", p))
1861 { 1870 {
1862 /* -print STRING: Print STRING on the terminal. */ 1871 /* -print STRING: Print STRING on the terminal. */
1863 str = unquote_argument (p + strlen ("-print ")); 1872 if (!suppress_output)
1864 if (needlf) 1873 {
1865 printf ("\n"); 1874 str = unquote_argument (p + strlen ("-print "));
1866 printf ("%s", str); 1875 if (needlf)
1867 needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n'; 1876 printf ("\n");
1868 } 1877 printf ("%s", str);
1878 needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n';
1879 }
1880 }
1869 else if (strprefix ("-print-nonl ", p)) 1881 else if (strprefix ("-print-nonl ", p))
1870 { 1882 {
1871 /* -print-nonl STRING: Print STRING on the terminal. 1883 /* -print-nonl STRING: Print STRING on the terminal.
1872 Used to continue a preceding -print command. */ 1884 Used to continue a preceding -print command. */
1873 str = unquote_argument (p + strlen ("-print-nonl ")); 1885 if (!suppress_output)
1874 printf ("%s", str); 1886 {
1875 needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n'; 1887 str = unquote_argument (p + strlen ("-print-nonl "));
1888 printf ("%s", str);
1889 needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n';
1890 }
1876 } 1891 }
1877 else if (strprefix ("-error ", p)) 1892 else if (strprefix ("-error ", p))
1878 { 1893 {