summaryrefslogtreecommitdiff
path: root/src/frame.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/frame.c')
-rw-r--r--src/frame.c59
1 files changed, 59 insertions, 0 deletions
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);