From: Kim F. Storm Date: Sun, 12 Jan 2003 20:24:06 +0000 (+0000) Subject: (QCvars): New variable. X-Git-Tag: ttn-vms-21-2-B4~11729 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=ac4a75846bff3dce4996bd97e1eb4325f4a65d34;p=emacs.git (QCvars): New variable. (syms_of_process): Intern and staticpro it. (Fprocess_variable, Fset_process_variable): New functions. (syms_of_process): Defsubr them. (Fstart_process): Initialize private_vars plist to nil. (Fmake_network_process): New arg :vars to setup the private variables for new network process. (server_accept_connection): Copy server's private variables to client process. --- diff --git a/src/process.c b/src/process.c index 70825a54ca0..24782504f05 100644 --- a/src/process.c +++ b/src/process.c @@ -132,7 +132,7 @@ Lisp_Object Qlocal, Qdatagram; Lisp_Object QCname, QCbuffer, QChost, QCservice, QCtype; Lisp_Object QClocal, QCremote, QCcoding; Lisp_Object QCserver, QCnowait, QCnoquery, QCstop; -Lisp_Object QCsentinel, QClog, QCoptions; +Lisp_Object QCsentinel, QClog, QCoptions, QCvars; Lisp_Object Qlast_nonmenu_event; /* QCfamily is declared and initialized in xfaces.c, QCfilter in keyboard.c. */ @@ -1037,20 +1037,34 @@ See `make-network-process' for a list of keywords. */) return Fplist_get (contact, key); } -DEFUN ("set-process-contact", Fset_process_contact, Sset_process_contact, - 3, 3, 0, - doc: /* Change value in PROCESS' contact information list of KEY to VAL. -If KEY is already a property on the list, its value is set to VAL, -otherwise the new KEY VAL pair is added. Returns VAL. */) - (process, key, val) - register Lisp_Object process, key, val; +DEFUN ("process-variable", Fprocess_variable, Sprocess_variable, + 1, 2, 0, + doc: /* Return the value of PROCESS' private variable VAR. +If VARIABLE is omitted or nil, return plist with all PROCESS variables. */) + (process, var) + register Lisp_Object process, var; { - Lisp_Object contact; + CHECK_PROCESS (process); + + if (NILP (var)) + return XPROCESS (process)->private_vars; + + return Fplist_get (XPROCESS (process)->private_vars, var); +} +DEFUN ("set-process-variable", Fset_process_variable, Sset_process_variable, + 3, 3, 0, + doc: /* Change value of PROCESS' private variable VAR to VAL, and return VAL. +If VAR is nil, set all PROCESS' private variables according to plist VAL. */) + (process, var, val) + register Lisp_Object process, var, val; +{ CHECK_PROCESS (process); - if (NETCONN_P (process)) - XPROCESS (process)->childp = Fplist_put (XPROCESS (process)->childp, key, val); + XPROCESS (process)->private_vars + = (NILP (var) + ? val + : Fplist_put (XPROCESS (process)->private_vars, var, val)); return val; } @@ -1420,6 +1434,7 @@ usage: (start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS) */) record_unwind_protect (start_process_unwind, proc); XPROCESS (proc)->childp = Qt; + XPROCESS (proc)->private_vars = Qnil; XPROCESS (proc)->command_channel_p = Qnil; XPROCESS (proc)->buffer = buffer; XPROCESS (proc)->sentinel = Qnil; @@ -2584,6 +2599,9 @@ client. The arguments are SERVER, CLIENT, and MESSAGE, where SERVER is the server process, CLIENT is the new process for the connection, and MESSAGE is a string. +:vars VARS -- Initialize the process' private variables according to +a list of variable/value pairs (VAR1 VAL1 VAR2 VAL2...). + :server BOOL -- if BOOL is non-nil, create a server process for the specified FAMILY, SERVICE, and connection type (stream or datagram). Default is a client process. @@ -2601,6 +2619,8 @@ NAME concatenated with the client identification string. inherited from the server process' TYPE, FILTER and SENTINEL. - The client process' contact info is set according to the client's addressing information (typically an IP address and a port number). +- The client process' private variables are initialized from the +server's private variables. Notice that the FILTER and SENTINEL args are never used directly by the server process. Also, the BUFFER argument is not used directly by @@ -2609,7 +2629,6 @@ failed) connections may be logged in the server process' buffer. The original argument list, modified with the actual connection information, is available via the `process-contact' function. -Additional arguments may be added via `set-process-contact'. usage: (make-network-process &rest ARGS) */) (nargs, args) @@ -3164,6 +3183,8 @@ usage: (make-network-process &rest ARGS) */) p = XPROCESS (proc); p->childp = contact; + p->private_vars = Fcopy_sequence (Fplist_get (contact, QCvars)); + p->buffer = buffer; p->sentinel = sentinel; p->filter = filter; @@ -3595,6 +3616,8 @@ server_accept_connection (server, channel) #endif p->childp = contact; + p->private_vars = Fcopy_sequence (ps->private_vars); + p->buffer = buffer; p->sentinel = ps->sentinel; p->filter = ps->filter; @@ -6320,6 +6343,8 @@ syms_of_process () staticpro (&QCstop); QCoptions = intern (":options"); staticpro (&QCoptions); + QCvars = intern (":vars"); + staticpro (&QCvars); Qlast_nonmenu_event = intern ("last-nonmenu-event"); staticpro (&Qlast_nonmenu_event); @@ -6363,7 +6388,8 @@ The value takes effect when `start-process' is called. */); defsubr (&Sset_process_query_on_exit_flag); defsubr (&Sprocess_query_on_exit_flag); defsubr (&Sprocess_contact); - defsubr (&Sset_process_contact); + defsubr (&Sprocess_variable); + defsubr (&Sset_process_variable); defsubr (&Slist_processes); defsubr (&Sprocess_list); defsubr (&Sstart_process);