changeset 4543:929e4c850e76

(term_get_fkeys_define_1, term_get_fkeys_define): New functions. (term_get_fkeys): Use them.
author Richard M. Stallman <rms@gnu.org>
date Wed, 11 Aug 1993 04:09:28 +0000
parents 87c959b66ae2
children 0e076941d4e3
files src/term.c
diffstat 1 files changed, 38 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/src/term.c	Tue Aug 10 21:30:51 1993 +0000
+++ b/src/term.c	Wed Aug 11 04:09:28 1993 +0000
@@ -1229,6 +1229,30 @@
   "k9",	"f9",
   };
 
+/* These subroutines are used to call
+   Fdefine_key inside of a condition-case.  */
+static Lisp_Object term_get_fkeys_data;
+
+extern Lisp_Object cmd_error ();
+
+static Lisp_Object
+term_get_fkeys_define_1 ()
+{
+  Fdefine_key (Vfunction_key_map, Fcar (term_get_fkeys_data),
+	       Fcdr (term_get_fkeys_data));
+  return Qnil;
+}
+
+/* Define KEY as DEFINITION in function-key-map, catching errors.  */
+
+static void
+term_get_fkeys_define (key, definition)
+     Lisp_Object key, definition;
+{
+  term_get_fkeys_data = Fcons (key, definition);
+  internal_condition_case (term_get_fkeys_define_1, Qerror, cmd_error);
+}
+
 /* Find the escape codes sent by the function keys for Vfunction_key_map.
    This function scans the termcap function key sequence entries, and 
    adds entries to Vfunction_key_map for each function key it finds.  */
@@ -1248,9 +1272,9 @@
     {
       char *sequence = tgetstr (keys[i].cap, address);
       if (sequence)
-	Fdefine_key (Vfunction_key_map,
-		     build_string (sequence),
-		     Fmake_vector (make_number (1), intern (keys[i].name)));
+	term_get_fkeys_define (build_string (sequence),
+			       Fmake_vector (make_number (1),
+					     intern (keys[i].name)));
     }
 
   /* The uses of the "k0" capability are inconsistent; sometimes it
@@ -1265,16 +1289,14 @@
 
     if (k_semi)
       {
-	Fdefine_key (Vfunction_key_map,
-		     build_string (k_semi),
-		     Fmake_vector (make_number (1), intern ("f10")));
+	term_get_fkeys_define (build_string (k_semi),
+			       Fmake_vector (make_number (1), intern ("f10")));
 	k0_name = "f0";
       }
 
     if (k0)
-      Fdefine_key (Vfunction_key_map,
-		   build_string (k0),
-		   Fmake_vector (make_number (1), intern (k0_name)));
+      term_get_fkeys_define (build_string (k0),
+			     Fmake_vector (make_number (1), intern (k0_name)));
   }
 
   /* Set up cookies for numbered function keys above f10. */
@@ -1295,10 +1317,10 @@
 	  char *sequence = tgetstr (fcap, address);
 	  if (sequence)
 	    {
-	      (void) sprintf (fkey, "f%d", i);	    
-	      Fdefine_key (Vfunction_key_map,
-			   build_string (sequence),
-			   Fmake_vector (make_number (1), intern (fkey)));
+	      sprintf (fkey, "f%d", i);
+	      term_get_fkeys_define (build_string (sequence),
+				     Fmake_vector (make_number (1),
+						   intern (fkey)));
 	    }
 	}
       }
@@ -1313,9 +1335,9 @@
 	{								\
 	  char *sequence = tgetstr (cap2, address);			\
 	  if (sequence)							\
-	    Fdefine_key (Vfunction_key_map,				\
-			 build_string (sequence),			\
-			 Fmake_vector (make_number (1), intern (sym)));	\
+	    term_get_fkeys_define (build_string (sequence),		\
+				   Fmake_vector (make_number (1),	\
+						 intern (sym)));	\
 	}
 	  
       /* if there's no key_next keycap, map key_npage to `next' keysym */