From f01b6d17cc07655d6ce62a4ac5097947529b81a2 Mon Sep 17 00:00:00 2001 From: Karoly Lorentey Date: Sat, 25 Jun 2005 16:34:30 +0000 Subject: [PATCH] Make function-key-map a terminal-local variable (move it inside the kboard struct). * src/keyboard.h (kboard): Move Vfunction_key_map inside the kboard struct. * src/keyboard.c (Vfunction_key_map): Remove declaration. (read_key_sequence, init_kboard): Update references to Vfunction_key_map. (syms_of_keyboard): Declare function-key-map as a terminal-local variable. (mark_kboards): Mark Vfunction_key_map. * src/keymap.c (Vfunction_key_map): Remove. (Fdescribe_buffer_bindings): Update references to Vfunction_key_map. (syms_of_keymap): Remove DEFVAR for Vfunction_key_map. * src/term.c (term_get_fkeys_1): Update references to Vfunction_key_map. git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-355 --- src/keyboard.c | 30 ++++++++++++++++++++++++++---- src/keyboard.h | 9 +++++---- src/keymap.c | 31 ++----------------------------- src/term.c | 14 +++++++------- 4 files changed, 40 insertions(+), 44 deletions(-) diff --git a/src/keyboard.c b/src/keyboard.c index 7f81dde35c7..13bf7131e0e 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -417,9 +417,6 @@ Lisp_Object Vtop_level; /* User-supplied table to translate input characters. */ Lisp_Object Vkeyboard_translate_table; -/* Keymap mapping ASCII function key sequences onto their preferred forms. */ -extern Lisp_Object Vfunction_key_map; - /* Another keymap that maps key sequences into key sequences. This one takes precedence over ordinary definitions. */ extern Lisp_Object Vkey_translation_map; @@ -8654,7 +8651,7 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, last_nonmenu_event = Qnil; delayed_switch_frame = Qnil; - fkey.map = fkey.parent = Vfunction_key_map; + fkey.map = fkey.parent = current_kboard->Vfunction_key_map; keytran.map = keytran.parent = Vkey_translation_map; /* If there is no translation-map, turn off scanning. */ fkey.start = fkey.end = KEYMAPP (fkey.map) ? 0 : bufsize + 1; @@ -10766,6 +10763,7 @@ init_kboard (kb) kb->reference_count = 0; kb->Vsystem_key_alist = Qnil; kb->system_key_syms = Qnil; + kb->Vfunction_key_map = Fmake_sparse_keymap (Qnil); kb->Vdefault_minibuffer_frame = Qnil; } @@ -11465,6 +11463,29 @@ Each element should have the form (N . SYMBOL) where N is the numeric keysym code (sans the \"system-specific\" bit 1<<28) and SYMBOL is its name. */); + DEFVAR_KBOARD ("function-key-map", Vfunction_key_map, + doc: /* Keymap mapping ASCII function key sequences onto their preferred forms. +This allows Emacs to recognize function keys sent from ASCII +terminals at any point in a key sequence. + +The `read-key-sequence' function replaces any subsequence bound by +`function-key-map' with its binding. More precisely, when the active +keymaps have no binding for the current key sequence but +`function-key-map' binds a suffix of the sequence to a vector or string, +`read-key-sequence' replaces the matching suffix with its binding, and +continues with the new sequence. + +The events that come from bindings in `function-key-map' are not +themselves looked up in `function-key-map'. + +For example, suppose `function-key-map' binds `ESC O P' to [f1]. +Typing `ESC O P' to `read-key-sequence' would return [f1]. Typing +`C-x ESC O P' would return [?\\C-x f1]. If [f1] were a prefix +key, typing `ESC O P x' would return [f1 x]. + +`function-key-map' has a separate binding for each display device. +See Info node `(elisp)Multiple displays'. */); + DEFVAR_LISP ("deferred-action-list", &Vdeferred_action_list, doc: /* List of deferred actions to be performed at a later time. The precise format isn't relevant here; we just check whether it is nil. */); @@ -11628,6 +11649,7 @@ mark_kboards () mark_object (kb->Vlast_kbd_macro); mark_object (kb->Vsystem_key_alist); mark_object (kb->system_key_syms); + mark_object (kb->Vfunction_key_map); mark_object (kb->Vdefault_minibuffer_frame); mark_object (kb->echo_string); } diff --git a/src/keyboard.h b/src/keyboard.h index 8ff1543d92e..d0d93603379 100644 --- a/src/keyboard.h +++ b/src/keyboard.h @@ -120,6 +120,11 @@ struct kboard /* Cache for modify_event_symbol. */ Lisp_Object system_key_syms; + /* Keymap mapping ASCII function key sequences onto their + preferred forms. Initialized by the terminal-specific lisp + files. See the DEFVAR for more documentation. */ + Lisp_Object Vfunction_key_map; + /* Minibufferless frames on this display use this frame's minibuffer. */ Lisp_Object Vdefault_minibuffer_frame; @@ -187,10 +192,6 @@ extern EMACS_INT num_nonmacro_input_events; /* Nonzero means polling for input is temporarily suppressed. */ extern int poll_suppress_count; -/* Keymap mapping ASCII function key sequences onto their preferred forms. - Initialized by the terminal-specific lisp files. */ -extern Lisp_Object Vfunction_key_map; - /* Vector holding the key sequence that invoked the current command. It is reused for each command, and it may be longer than the current sequence; this_command_key_count indicates how many elements diff --git a/src/keymap.c b/src/keymap.c index 3706ad52c9e..1734ac1baa9 100644 --- a/src/keymap.c +++ b/src/keymap.c @@ -79,11 +79,6 @@ Lisp_Object Vminor_mode_overriding_map_alist; /* List of emulation mode keymap alists. */ Lisp_Object Vemulation_mode_map_alists; -/* Keymap mapping ASCII function key sequences onto their preferred forms. - Initialized by the terminal-specific lisp files. See DEFVAR for more - documentation. */ -Lisp_Object Vfunction_key_map; - /* Keymap mapping ASCII function key sequences onto their preferred forms. */ Lisp_Object Vkey_translation_map; @@ -2939,8 +2934,8 @@ You type Translation\n\ "\f\nGlobal Bindings", nomenu, 0, 1, 0); /* Print the function-key-map translations under this prefix. */ - if (!NILP (Vfunction_key_map)) - describe_map_tree (Vfunction_key_map, 0, Qnil, prefix, + if (!NILP (current_kboard->Vfunction_key_map)) + describe_map_tree (current_kboard->Vfunction_key_map, 0, Qnil, prefix, "\f\nFunction key map translations", nomenu, 1, 0, 0); UNGCPRO; @@ -3802,28 +3797,6 @@ the same way. The "active" keymaps in each alist are used before `minor-mode-map-alist' and `minor-mode-overriding-map-alist'. */); Vemulation_mode_map_alists = Qnil; - - DEFVAR_LISP ("function-key-map", &Vfunction_key_map, - doc: /* Keymap mapping ASCII function key sequences onto their preferred forms. -This allows Emacs to recognize function keys sent from ASCII -terminals at any point in a key sequence. - -The `read-key-sequence' function replaces any subsequence bound by -`function-key-map' with its binding. More precisely, when the active -keymaps have no binding for the current key sequence but -`function-key-map' binds a suffix of the sequence to a vector or string, -`read-key-sequence' replaces the matching suffix with its binding, and -continues with the new sequence. - -The events that come from bindings in `function-key-map' are not -themselves looked up in `function-key-map'. - -For example, suppose `function-key-map' binds `ESC O P' to [f1]. -Typing `ESC O P' to `read-key-sequence' would return [f1]. Typing -`C-x ESC O P' would return [?\\C-x f1]. If [f1] were a prefix -key, typing `ESC O P x' would return [f1 x]. */); - Vfunction_key_map = Fmake_sparse_keymap (Qnil); - DEFVAR_LISP ("key-translation-map", &Vkey_translation_map, doc: /* Keymap of key translations that can override keymaps. This keymap works like `function-key-map', but comes after that, diff --git a/src/term.c b/src/term.c index 774373e82f9..51d191a3bfc 100644 --- a/src/term.c +++ b/src/term.c @@ -1344,13 +1344,13 @@ term_get_fkeys_1 () /* This can happen if CANNOT_DUMP or with strange options. */ if (!initialized) - Vfunction_key_map = Fmake_sparse_keymap (Qnil); + current_kboard->Vfunction_key_map = Fmake_sparse_keymap (Qnil); for (i = 0; i < (sizeof (keys)/sizeof (keys[0])); i++) { char *sequence = tgetstr (keys[i].cap, address); if (sequence) - Fdefine_key (Vfunction_key_map, build_string (sequence), + Fdefine_key (current_kboard->Vfunction_key_map, build_string (sequence), Fmake_vector (make_number (1), intern (keys[i].name))); } @@ -1370,13 +1370,13 @@ term_get_fkeys_1 () if (k0) /* Define f0 first, so that f10 takes precedence in case the key sequences happens to be the same. */ - Fdefine_key (Vfunction_key_map, build_string (k0), + Fdefine_key (current_kboard->Vfunction_key_map, build_string (k0), Fmake_vector (make_number (1), intern ("f0"))); - Fdefine_key (Vfunction_key_map, build_string (k_semi), + Fdefine_key (current_kboard->Vfunction_key_map, build_string (k_semi), Fmake_vector (make_number (1), intern ("f10"))); } else if (k0) - Fdefine_key (Vfunction_key_map, build_string (k0), + Fdefine_key (current_kboard->Vfunction_key_map, build_string (k0), Fmake_vector (make_number (1), intern (k0_name))); } @@ -1399,7 +1399,7 @@ term_get_fkeys_1 () if (sequence) { sprintf (fkey, "f%d", i); - Fdefine_key (Vfunction_key_map, build_string (sequence), + Fdefine_key (current_kboard->Vfunction_key_map, build_string (sequence), Fmake_vector (make_number (1), intern (fkey))); } @@ -1416,7 +1416,7 @@ term_get_fkeys_1 () { \ char *sequence = tgetstr (cap2, address); \ if (sequence) \ - Fdefine_key (Vfunction_key_map, build_string (sequence), \ + Fdefine_key (current_kboard->Vfunction_key_map, build_string (sequence), \ Fmake_vector (make_number (1), \ intern (sym))); \ } -- 2.39.2