diff src/frame.c @ 83427:2afc49c9f0c0

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
author Karoly Lorentey <lorentey@elte.hu>
date Thu, 29 Dec 2005 04:31:04 +0000
parents 521d3f18b3d1
children 76396de7f50a
line wrap: on
line diff
--- a/src/frame.c	Thu Dec 29 02:10:23 2005 +0000
+++ b/src/frame.c	Thu Dec 29 04:31:04 2005 +0000
@@ -111,6 +111,7 @@
 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 @@
   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 @@
 
   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 @@
   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 @@
   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);