aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src
diff options
context:
space:
mode:
authorGregory Heytings2021-11-05 00:14:30 +0100
committerLars Ingebrigtsen2021-11-05 00:14:30 +0100
commit2bcc2160c9f7f16c5e9cd815b8074de27f30896d (patch)
tree82fe7f4ff83a6d65e24384cd1e2eb70f15dbcac3 /lib-src
parenta78ac0c5df74be6925f48896fd024f1f6f363c44 (diff)
downloademacs-2bcc2160c9f7f16c5e9cd815b8074de27f30896d.tar.gz
emacs-2bcc2160c9f7f16c5e9cd815b8074de27f30896d.zip
New emacsclient option to either create or reuse an existing frame.
* doc/emacs/misc.texi (emacsclient Options): Document the new option. * doc/man/emacsclient.1: Mention the new option (bug#51374). * etc/NEWS: Mention the new option. * lib-src/emacsclient.c (reuse_frame): New variable. (longopts): New option. (decode_options): Decode the new option. (print_help_and_exit): Document the new option. (main): Use the new option.
Diffstat (limited to 'lib-src')
-rw-r--r--lib-src/emacsclient.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c
index cff3cec2a79..0e800dd7e89 100644
--- a/lib-src/emacsclient.c
+++ b/lib-src/emacsclient.c
@@ -116,6 +116,9 @@ static bool eval;
116/* True means open a new frame. --create-frame etc. */ 116/* True means open a new frame. --create-frame etc. */
117static bool create_frame; 117static bool create_frame;
118 118
119/* True means reuse a frame if it already exists. */
120static bool reuse_frame;
121
119/* The display on which Emacs should work. --display. */ 122/* The display on which Emacs should work. --display. */
120static char const *display; 123static char const *display;
121 124
@@ -165,6 +168,7 @@ static struct option const longopts[] =
165 { "tty", no_argument, NULL, 't' }, 168 { "tty", no_argument, NULL, 't' },
166 { "nw", no_argument, NULL, 't' }, 169 { "nw", no_argument, NULL, 't' },
167 { "create-frame", no_argument, NULL, 'c' }, 170 { "create-frame", no_argument, NULL, 'c' },
171 { "reuse-frame", no_argument, NULL, 'r' },
168 { "alternate-editor", required_argument, NULL, 'a' }, 172 { "alternate-editor", required_argument, NULL, 'a' },
169 { "frame-parameters", required_argument, NULL, 'F' }, 173 { "frame-parameters", required_argument, NULL, 'F' },
170#ifdef SOCKETS_IN_FILE_SYSTEM 174#ifdef SOCKETS_IN_FILE_SYSTEM
@@ -551,6 +555,11 @@ decode_options (int argc, char **argv)
551 create_frame = true; 555 create_frame = true;
552 break; 556 break;
553 557
558 case 'r':
559 create_frame = true;
560 reuse_frame = true;
561 break;
562
554 case 'p': 563 case 'p':
555 parent_id = optarg; 564 parent_id = optarg;
556 create_frame = true; 565 create_frame = true;
@@ -647,6 +656,8 @@ The following OPTIONS are accepted:\n\
647-nw, -t, --tty Open a new Emacs frame on the current terminal\n\ 656-nw, -t, --tty Open a new Emacs frame on the current terminal\n\
648-c, --create-frame Create a new frame instead of trying to\n\ 657-c, --create-frame Create a new frame instead of trying to\n\
649 use the current Emacs frame\n\ 658 use the current Emacs frame\n\
659-r, --reuse-frame Create a new frame if none exists, otherwise\n\
660 use the current Emacs frame\n\
650", "\ 661", "\
651-F ALIST, --frame-parameters=ALIST\n\ 662-F ALIST, --frame-parameters=ALIST\n\
652 Set the parameters of a new frame\n\ 663 Set the parameters of a new frame\n\
@@ -1941,7 +1952,7 @@ main (int argc, char **argv)
1941 if (nowait) 1952 if (nowait)
1942 send_to_emacs (emacs_socket, "-nowait "); 1953 send_to_emacs (emacs_socket, "-nowait ");
1943 1954
1944 if (!create_frame) 1955 if (!create_frame || reuse_frame)
1945 send_to_emacs (emacs_socket, "-current-frame "); 1956 send_to_emacs (emacs_socket, "-current-frame ");
1946 1957
1947 if (display) 1958 if (display)