summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKaroly Lorentey <lorentey@elte.hu>2005-12-29 04:31:04 +0000
committerKaroly Lorentey <lorentey@elte.hu>2005-12-29 04:31:04 +0000
commitda8e8fc14f3166ec596e34f43fbfea866d1176df (patch)
tree9c31affcb4b837cac4793f10acbafc562bfd08e4 /src
parent86f5ca04d94ad551d3aa726e15281e75ef0189ed (diff)
downloademacs-da8e8fc14f3166ec596e34f43fbfea866d1176df.tar.gz
emacs-da8e8fc14f3166ec596e34f43fbfea866d1176df.tar.bz2
emacs-da8e8fc14f3166ec596e34f43fbfea866d1176df.zip
Store local environment in frame (not terminal) parameters.
* src/callproc.c (child_setup, getenv_internal, Fgetenv_internal): Store the local environment in a frame (not terminal) parameter. Update doc strings. (syms_of_callproc): Update doc strings. (Qenvironment): Moved to frame.c. * lisp/env.el (read-envvar-name, setenv, getenv, environment): Use frame parameters to store the local environment, not terminal parameters. * server.el (server-process-filter): Store the local environment in a frame (not terminal) parameter. Do not try to decode environment strings. * lisp/frame.el (make-frame): Set up the 'environment frame parameter, when needed. * src/frame.c (Qenvironment): Move here from callproc.c. (Fdelete_frame): Don't allow other frames to refer to a deleted frame in their 'environment parameter. (Fframe_with_environment): New function. (syms_of_frame): Defsubr it. Initialize and staticpro Qenvironment. * frame.h (Qenvironment): Declare. * lisp.h (Fframe_with_environment): EXFUN it. git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-467
Diffstat (limited to 'src')
-rw-r--r--src/callproc.c71
-rw-r--r--src/frame.c59
-rw-r--r--src/frame.h1
-rw-r--r--src/lisp.h1
4 files changed, 94 insertions, 38 deletions
diff --git a/src/callproc.c b/src/callproc.c
index ee702fef8c7..715178f8fb2 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -119,7 +119,6 @@ Lisp_Object Vprocess_environment;
#ifdef DOS_NT
Lisp_Object Qbuffer_file_type;
#endif /* DOS_NT */
-Lisp_Object Qenvironment;
/* True iff we are about to fork off a synchronous process or if we
are waiting for it. */
@@ -1319,8 +1318,8 @@ child_setup (in, out, err, new_argv, set_pgrp, current_dir)
if (!NILP (Vlocal_environment_variables))
{
- local = get_terminal_param (FRAME_DEVICE (XFRAME (selected_frame)),
- Qenvironment);
+ local = get_frame_param (XFRAME (Fframe_with_environment (selected_frame)),
+ Qenvironment);
if (EQ (Vlocal_environment_variables, Qt)
&& !NILP (local))
environment = local;
@@ -1356,7 +1355,7 @@ child_setup (in, out, err, new_argv, set_pgrp, current_dir)
new_env = add_env (env, new_env, egetenv (SDATA (XCAR (tem))));
/* The rest of the environment (either Vglobal_environment or the
- 'environment terminal parameter). */
+ 'environment frame parameter). */
for (tem = environment;
CONSP (tem) && STRINGP (XCAR (tem));
tem = XCDR (tem))
@@ -1488,12 +1487,12 @@ relocate_fd (fd, minfd)
}
static int
-getenv_internal (var, varlen, value, valuelen, terminal)
+getenv_internal (var, varlen, value, valuelen, frame)
char *var;
int varlen;
char **value;
int *valuelen;
- Lisp_Object terminal;
+ Lisp_Object frame;
{
Lisp_Object scan;
Lisp_Object environment = Vglobal_environment;
@@ -1528,17 +1527,19 @@ getenv_internal (var, varlen, value, valuelen, terminal)
}
/* Find the environment in which to search the variable. */
- if (!NILP (terminal))
+ if (!NILP (frame))
{
- Lisp_Object local = get_terminal_param (get_device (terminal, 1), Qenvironment);
+ CHECK_FRAME (frame);
+ frame = Fframe_with_environment (frame);
+ Lisp_Object local = get_frame_param (XFRAME (frame), Qenvironment);
/* Use Vglobal_environment if there is no local environment. */
if (!NILP (local))
environment = local;
}
else if (!NILP (Vlocal_environment_variables))
{
- Lisp_Object local = get_terminal_param (FRAME_DEVICE (XFRAME (selected_frame)),
- Qenvironment);
+ Lisp_Object local = get_frame_param (XFRAME (Fframe_with_environment (selected_frame)),
+ Qenvironment);
if (EQ (Vlocal_environment_variables, Qt)
&& !NILP (local))
environment = local;
@@ -1594,25 +1595,23 @@ DEFUN ("getenv-internal", Fgetenv_internal, Sgetenv_internal, 1, 2, 0,
VARIABLE should be a string. Value is nil if VARIABLE is undefined in
the environment. Otherwise, value is a string.
-If optional parameter TERMINAL is non-nil, then it should be a
-terminal id or a frame. If the specified terminal device has its own
-set of environment variables, this function will look up VARIABLE in
-it.
+If optional parameter FRAME is non-nil, then it should be a frame. If
+that frame has its own set of environment variables, this function
+will look up VARIABLE in there.
Otherwise, this function searches `process-environment' for VARIABLE.
If it was not found there, then it continues the search in either
`global-environment' or the local environment list of the current
-terminal device, depending on the value of
-`local-environment-variables'. */)
- (variable, terminal)
- Lisp_Object variable, terminal;
+frame, depending on the value of `local-environment-variables'. */)
+ (variable, frame)
+ Lisp_Object variable, frame;
{
char *value;
int valuelen;
CHECK_STRING (variable);
if (getenv_internal (SDATA (variable), SBYTES (variable),
- &value, &valuelen, terminal))
+ &value, &valuelen, frame))
return make_string (value, valuelen);
else
return Qnil;
@@ -1842,11 +1841,10 @@ Each element should be a string of the form ENVVARNAME=VALUE.
The environment which Emacs inherits is placed in this variable when
Emacs starts.
-Some terminal devices may have their own local list of environment
-variables in their 'environment parameter, which may override this
-global list; see `local-environment-variables'. See
-`process-environment' for a way to modify an environment variable on
-all terminals.
+Some frames may have their own local list of environment variables in
+their 'environment parameter, which may override this global list; see
+`local-environment-variables'. See `process-environment' for a way to
+modify an environment variable on all frames.
If multiple entries define the same variable, the first one always
takes precedence.
@@ -1860,12 +1858,12 @@ See `setenv' and `getenv'. */);
Each element should be a string of the form ENVVARNAME=VALUE.
Entries in this list take precedence to those in `global-environment'
-or the terminal environment. (See `local-environment-variables' for
-an explanation of the terminal-local environment.) Therefore,
-let-binding `process-environment' is an easy way to temporarily change
-the value of an environment variable, irrespective of where it comes
-from. To use `process-environment' to remove an environment variable,
-include only its name in the list, without "=VALUE".
+or the frame-local environment. (See `local-environment-variables'.)
+Therefore, let-binding `process-environment' is an easy way to
+temporarily change the value of an environment variable, irrespective
+of where it comes from. To use `process-environment' to remove an
+environment variable, include only its name in the list, without
+"=VALUE".
This variable is set to nil when Emacs starts.
@@ -1886,21 +1884,18 @@ See `setenv' and `getenv'. */);
defsubr (&Scall_process_region);
DEFVAR_LISP ("local-environment-variables", &Vlocal_environment_variables,
- doc: /* Enable or disable terminal-local environment variables.
+ doc: /* Enable or disable frame-local environment variables.
If set to t, `getenv', `setenv' and subprocess creation functions use
-the local environment of the terminal device of the selected frame,
-ignoring `global-environment'.
+the local environment of the selected frame, ignoring
+`global-environment'.
If set to nil, Emacs uses `global-environment' and ignores the
-terminal environment.
+frame-local environment.
Otherwise, `local-environment-variables' should be a list of variable
-names (represented by Lisp strings) to look up in the terminal's
+names (represented by Lisp strings) to look up in the frame's
environment. The rest will come from `global-environment'. */);
Vlocal_environment_variables = Qnil;
-
- Qenvironment = intern ("environment");
- staticpro (&Qenvironment);
}
/* arch-tag: 769b8045-1df7-4d2b-8968-e3fb49017f95
diff --git a/src/frame.c b/src/frame.c
index c3140628cec..f0657975402 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -111,6 +111,7 @@ Lisp_Object Qbuffer_predicate, Qbuffer_list, Qburied_buffer_list;
Lisp_Object Qtty_color_mode;
Lisp_Object Qtty, Qtty_type;
Lisp_Object Qwindow_system;
+Lisp_Object Qenvironment;
Lisp_Object Qfullscreen, Qfullwidth, Qfullheight, Qfullboth;
@@ -1473,6 +1474,24 @@ The functions are run with one arg, the frame to be deleted. */)
if (EQ (f->minibuffer_window, echo_area_window))
echo_area_window = sf->minibuffer_window;
+ /* Don't allow other frames to refer to a deleted frame in their
+ 'environment parameter. */
+ {
+ Lisp_Object tail, frame1;
+ Lisp_Object env = get_frame_param (XFRAME (frame), Qenvironment);
+ FOR_EACH_FRAME (tail, frame1)
+ {
+ if (EQ (frame, frame1) || !FRAME_LIVE_P (XFRAME (frame1)))
+ continue;
+ if (EQ (frame, get_frame_param (XFRAME (frame1), Qenvironment)))
+ {
+ store_frame_param (XFRAME (frame1), Qenvironment, env);
+ if (!FRAMEP (env))
+ env = frame1;
+ }
+ }
+ }
+
/* Clear any X selections for this frame. */
#ifdef HAVE_X_WINDOWS
if (FRAME_X_P (f))
@@ -2577,6 +2596,43 @@ enabled such bindings for that variable with `make-variable-frame-local'. */)
return unbind_to (count, Qnil);
}
+
+DEFUN ("frame-with-environment", Fframe_with_environment, Sframe_with_environment, 0, 1, 0,
+ doc: /* Return the frame that has the environment variable list for FRAME.
+
+The frame-local environment variable list is normally shared between
+frames that were created in the same Emacsclient session. The
+environment list is stored in a single frame's 'environment parameter;
+the other frames' 'environment parameter is set to this frame. This
+function follows to chain of 'environment references to reach the
+frame that stores the actual local environment list, and returns that
+frame. */)
+ (frame)
+ Lisp_Object frame;
+{
+ Lisp_Object hare, tortoise;
+
+ if (NILP (frame))
+ frame = selected_frame;
+ CHECK_FRAME (frame);
+
+ hare = tortoise = get_frame_param (XFRAME (frame), Qenvironment);
+ while (!NILP (hare) && FRAMEP (hare))
+ {
+ frame = hare;
+ hare = get_frame_param (XFRAME (hare), Qenvironment);
+ if (NILP (hare) || !FRAMEP (hare))
+ break;
+ frame = hare;
+ hare = get_frame_param (XFRAME (hare), Qenvironment);
+ tortoise = get_frame_param (XFRAME (tortoise), Qenvironment);
+ if (EQ (hare, tortoise))
+ error ("Cyclic frame-local environment indirection");
+ }
+
+ return frame;
+}
+
DEFUN ("frame-char-height", Fframe_char_height, Sframe_char_height,
0, 1, 0,
@@ -4232,6 +4288,8 @@ syms_of_frame ()
staticpro (&Qtty_type);
Qwindow_system = intern ("window-system");
staticpro (&Qwindow_system);
+ Qenvironment = intern ("environment");
+ staticpro (&Qenvironment);
Qface_set_after_frame_default = intern ("face-set-after-frame-default");
staticpro (&Qface_set_after_frame_default);
@@ -4416,6 +4474,7 @@ This variable is local to the current terminal and cannot be buffer-local. */);
defsubr (&Sframe_parameters);
defsubr (&Sframe_parameter);
defsubr (&Smodify_frame_parameters);
+ defsubr (&Sframe_with_environment);
defsubr (&Sframe_char_height);
defsubr (&Sframe_char_width);
defsubr (&Sframe_pixel_height);
diff --git a/src/frame.h b/src/frame.h
index c63b0bec464..6c54c328923 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -781,6 +781,7 @@ typedef struct frame *FRAME_PTR;
extern Lisp_Object Qframep, Qframe_live_p;
extern Lisp_Object Qtty, Qtty_type;
extern Lisp_Object Qdevice, Qdisplay_live_p;
+extern Lisp_Object Qenvironment;
extern struct frame *last_nonminibuf_frame;
diff --git a/src/lisp.h b/src/lisp.h
index 4b71cd67e98..0aa2d7cb510 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -2998,6 +2998,7 @@ EXFUN (Fvisible_frame_list, 0);
EXFUN (Fframe_parameter, 2);
EXFUN (Fframe_parameters, 1);
EXFUN (Fmodify_frame_parameters, 2);
+EXFUN (Fframe_with_environment, 1);
EXFUN (Fset_frame_height, 3);
EXFUN (Fset_frame_width, 3);
EXFUN (Fset_frame_size, 3);