changeset 6248:0e4319197d29

(term_get_fkeys_data): Variable removed. (term_get_fkeys_define_1, term_get_fkeys_define): Functions removed. (term_get_fkeys_address): New variable, to pass arg through condition-case. (term_get_fkeys): Set that to ADDRESS; just do condition-case around call to term_get_fkeys_1, ignoring all errors. (term_get_fkeys_1): New function, containing body of term_get_fkeys. Don't use term_get_fkeys_define_1; call Fdefine_key directly.
author Roland McGrath <roland@gnu.org>
date Tue, 08 Mar 1994 06:20:26 +0000
parents 22d4037cbce2
children 365e7cbd7292
files src/term.c
diffstat 1 files changed, 33 insertions(+), 37 deletions(-) [+]
line wrap: on
line diff
--- a/src/term.c	Tue Mar 08 06:20:18 1994 +0000
+++ b/src/term.c	Tue Mar 08 06:20:26 1994 +0000
@@ -1,5 +1,5 @@
 /* terminal control module for terminals described by TERMCAP
-   Copyright (C) 1985, 1986, 1987, 1993 Free Software Foundation, Inc.
+   Copyright (C) 1985, 1986, 1987, 1993, 1994 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -1229,29 +1229,8 @@
   "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);
-}
+static char **term_get_fkeys_arg;
+static Lisp_Object term_get_fkeys_1 ();
 
 /* Find the escape codes sent by the function keys for Vfunction_key_map.
    This function scans the termcap function key sequence entries, and 
@@ -1261,6 +1240,23 @@
 term_get_fkeys (address)
      char **address;
 {
+  /* We run the body of the function (term_get_fkeys_1) and ignore all Lisp
+     errors during the call.  The only errors should be from Fdefine_key
+     when given a key sequence containing an invalid prefix key.  If the
+     termcap defines function keys which use a prefix that is already bound
+     to a command by the default bindings, we should silently ignore that
+     function key specification, rather than giving the user an error and
+     refusing to run at all on such a terminal.  */
+
+  extern Lisp_Object Fidentity ();
+  static Lisp_Object term_get_fkeys_1 ();
+  term_get_fkeys_arg = address;
+  internal_condition_case (term_get_fkeys_1, Qerror, Fidentity);
+}
+
+static Lisp_Object
+term_get_fkeys_1 ()
+{
   extern char *tgetstr ();
   int i;
 
@@ -1272,9 +1268,9 @@
     {
       char *sequence = tgetstr (keys[i].cap, address);
       if (sequence)
-	term_get_fkeys_define (build_string (sequence),
-			       Fmake_vector (make_number (1),
-					     intern (keys[i].name)));
+	Fdefine_key (Vfunction_key_map, build_string (sequence),
+		     Fmake_vector (make_number (1),
+				   intern (keys[i].name)));
     }
 
   /* The uses of the "k0" capability are inconsistent; sometimes it
@@ -1289,14 +1285,14 @@
 
     if (k_semi)
       {
-	term_get_fkeys_define (build_string (k_semi),
-			       Fmake_vector (make_number (1), intern ("f10")));
+	Fdefine_key (Vfunction_key_map, build_string (k_semi),
+		     Fmake_vector (make_number (1), intern ("f10")));
 	k0_name = "f0";
       }
 
     if (k0)
-      term_get_fkeys_define (build_string (k0),
-			     Fmake_vector (make_number (1), intern (k0_name)));
+      Fdefine_key (Vfunction_key_map, build_string (k0),
+		   Fmake_vector (make_number (1), intern (k0_name)));
   }
 
   /* Set up cookies for numbered function keys above f10. */
@@ -1318,9 +1314,9 @@
 	  if (sequence)
 	    {
 	      sprintf (fkey, "f%d", i);
-	      term_get_fkeys_define (build_string (sequence),
-				     Fmake_vector (make_number (1),
-						   intern (fkey)));
+	      Fdefine_key (Vfunction_key_map, build_string (sequence),
+			   Fmake_vector (make_number (1),
+					 intern (fkey)));
 	    }
 	}
       }
@@ -1335,9 +1331,9 @@
 	{								\
 	  char *sequence = tgetstr (cap2, address);			\
 	  if (sequence)							\
-	    term_get_fkeys_define (build_string (sequence),		\
-				   Fmake_vector (make_number (1),	\
-						 intern (sym)));	\
+	    Fdefine_key (Vfunction_key_map, build_string (sequence),	\
+			 Fmake_vector (make_number (1),	\
+				       intern (sym)));	\
 	}
 	  
       /* if there's no key_next keycap, map key_npage to `next' keysym */