changeset 1385:a4a205bdd2c1

* frame.c: #include "commands.h" and "keyboard.h". (Fselect_frame): Make this interactive, and accept switch-frame events as arguments, so we can bind this function to switch-frame events. (keys_of_frame): New function; bind switch-frame to Fselect_frame.
author Jim Blandy <jimb@redhat.com>
date Sun, 11 Oct 1992 06:40:57 +0000
parents 416f7f33fe95
children 5845050f9d5c
files src/frame.c
diffstat 1 files changed, 27 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/frame.c	Sun Oct 11 06:40:24 1992 +0000
+++ b/src/frame.c	Sun Oct 11 06:40:57 1992 +0000
@@ -28,6 +28,10 @@
 #include "window.h"
 #include "termhooks.h"
 
+/* These help us bind and responding to switch-frame events.  */
+#include "commands.h"
+#include "keyboard.h"
+
 Lisp_Object Vemacs_iconified;
 Lisp_Object Vframe_list;
 Lisp_Object Vterminal_frame;
@@ -313,13 +317,25 @@
   return f;
 }
 
-DEFUN ("select-frame", Fselect_frame, Sselect_frame, 1, 2, 0,
+DEFUN ("select-frame", Fselect_frame, Sselect_frame, 1, 2, "e",
   "Select the frame FRAME.  FRAME's selected window becomes \"the\"\n\
 selected window.  If the optional parameter NO-ENTER is non-nil, don't\n\
-focus on that frame.")
+focus on that frame.\n\
+\n\
+This function is interactive, and may be bound to the ``switch-frame''\n\
+event; when invoked this way, it switches to the frame named in the\n\
+event.  When called from lisp, FRAME may be a ``switch-frame'' event;\n\
+if it is, select the frame named in the event.")
   (frame, no_enter)
      Lisp_Object frame, no_enter;
 {
+  /* If FRAME is a switch-frame event, extract the frame we should
+     switch to.  */
+  if (CONSP (frame)
+      && EQ (XCONS (frame)->car, Qswitch_frame)
+      && CONSP (XCONS (frame)->cdr))
+    frame = XCONS (XCONS (frame)->cdr)->car;
+
   CHECK_LIVE_FRAME (frame, 0);
 
   if (selected_frame == XFRAME (frame))
@@ -1364,6 +1380,11 @@
 #endif	/* HAVE_X11 */
 }
 
+keys_of_frame ()
+{
+  initial_define_lispy_key (global_map, "switch-frame", "select-frame");
+}
+
 #else /* not MULTI_FRAME */
 
 /* If we're not using multi-frame stuff, we still need to provide some
@@ -1475,6 +1496,10 @@
   Ffset (intern ("screen-width"), intern ("frame-width"));
 }
 
+keys_of_frame ()
+{
+}
+
 #endif /* not MULTI_FRAME */