annotate lisp/tmm.el @ 112364:42e22c4f06b7

Move all DEFVAR'd globals into a structure -- threading infrastructure * globals.h: New file. * xterm.h (Vx_pixel_size_width_font_regexp): Remove declaration. * window.h (Vinitial_window_system, Vminibuf_scroll_window) (Vwindow_system_version): Remove declaration. * w32term.h (Vw32_enable_palette) (Vx_pixel_size_width_font_regexp): Remove declaration. * w32menu.c (Voverriding_local_map) (Voverriding_local_map_menu_flag): Remove declaration. * w32inevt.c (Vw32_alt_is_meta, Vw32_apps_modifier) (Vw32_capslock_is_shiftlock, Vw32_enable_caps_lock) (Vw32_enable_num_lock, Vw32_lwindow_modifier) (Vw32_pass_lwindow_to_system, Vw32_pass_rwindow_to_system) (Vw32_phantom_key_code, Vw32_recognize_altgr) (Vw32_rwindow_modifier, Vw32_scroll_lock_modifier) (w32_use_full_screen_buffer): Remove declaration. * w32.c (Vsystem_configuration, Vw32_downcase_file_names) (Vw32_generate_fake_inodes, Vw32_get_true_file_attributes) (w32_num_mouse_buttons, w32_pipe_read_delay): Remove declaration. * termopts.h (Vtruncate_partial_width_windows, inverse_video) (no_redraw_on_reenter, visible_bell): Remove declaration. * sysdep.c (Vsystem_name): Remove declaration. * syntax.h (parse_sexp_lookup_properties): Remove declaration. * menu.h (Vmenu_updating_frame): Remove declaration. * macros.h (Vexecuting_kbd_macro, executing_kbd_macro_index): Remove declaration. * lisp.h (Vafter_init_time, Vafter_load_alist) (Vauto_save_list_file_name, Vbefore_init_time, Vcommand_history) (Vcompletion_regexp_list, Vcurrent_load_list) (Vcurrent_prefix_arg, Vdata_directory, Vdebug_on_error) (Vdoc_directory, Vdoc_file_name, Vdynamic_library_alist) (Vexec_directory, Vexec_path, Vexec_suffixes) (Vface_font_rescale_alist, Vface_ignored_fonts, Vfeatures) (Vhelp_form, Vhistory_length, Vinhibit_field_text_motion) (Vinhibit_quit, Vinhibit_read_only, Vinhibit_redisplay) (Vinstallation_directory, Vinvocation_directory) (Vinvocation_name, Vload_file_rep_suffixes, Vload_history) (Vload_suffixes, Vmark_even_if_inactive, Vmemory_full) (Vmessage_log_max, Vobarray, Vprint_length, Vprint_level) (Vpurify_flag, Vquit_flag, Vsaved_region_selection) (Vscalable_fonts_allowed, Vselect_active_regions) (Vshell_file_name, Vstandard_input, Vstandard_output) (Vsystem_name, Vtemporary_file_directory, Vthrow_on_input) (Vtop_level, Vtty_erase_char, Vundo_outer_limit) (Vuser_login_name, Vwindow_scroll_functions) (Vwindow_system_version, Vx_no_window_manager) (Vx_resource_class, Vx_resource_name, baud_rate) (completion_ignore_case, debug_on_next_call, gc_cons_threshold) (history_delete_duplicates, inhibit_x_resources) (last_nonmenu_event, load_in_progress, max_specpdl_size) (minibuffer_auto_raise, print_escape_newlines, scroll_margin) (use_dialog_box, use_file_dialog): Remove declaration. Include globals.h. * keymap.h (Voverriding_local_map) (Voverriding_local_map_menu_flag, meta_prefix_char): Remove declaration. * keyboard.h (Vdouble_click_time, Vfunction_key_map) (Vinput_method_function, Vkey_translation_map) (Vlucid_menu_bar_dirty_flag, Vthis_original_command) (do_mouse_tracking, extra_keyboard_modifiers) (num_nonmacro_input_events): Remove declaration. * intervals.h (Vchar_property_alias_alist) (Vdefault_text_properties, Vinhibit_point_motion_hooks) (Vtext_property_default_nonsticky): Remove declaration. * gtkutil.h (x_gtk_file_dialog_help_text) (x_gtk_show_hidden_files, x_gtk_use_old_file_dialog) (x_gtk_whole_detached_tool_bar): Remove declaration. * frame.h (Vdefault_frame_alist, Vframe_alpha_lower_limit) (Vmenu_bar_mode, Vmouse_highlight, Vterminal_frame) (Vtool_bar_mode, Vx_resource_class, Vx_resource_name) (focus_follows_mouse): Remove declaration. * fontset.h (Valternate_fontname_alist, Vfontset_alias_alist) (Vignore_relative_composition, Votf_script_alist) (Vuse_default_ascent, Vvertical_centering_font_regexp): Remove declaration. * font.h (Vfont_log): Remove declaration. * dosfns.h (Vdos_display_scancodes, Vdos_version) (Vdos_windows_version, dos_codepage, dos_country_code) (dos_decimal_point, dos_hyper_key, dos_keyboard_layout) (dos_keypad_mode, dos_super_key, dos_timezone_offset): Remove declaration. * disptab.h (Vglyph_table, Vstandard_display_table): Remove declaration. * dispextern.h (Vface_remapping_alist, Vglyphless_char_display) (Vmouse_autoselect_window, Voverflow_newline_into_fringe) (Vshow_trailing_whitespace, Vtool_bar_button_margin) (Vtool_bar_style, cursor_in_echo_area, display_hourglass_p) (inverse_video, mode_line_in_non_selected_windows) (tool_bar_button_relief, tool_bar_max_label_size) (underline_minimum_offset) (unibyte_display_via_language_environment, x_stretch_cursor_p): Remove declaration. * composite.h (Vauto_composition_function) (Vcomposition_function_table): Remove declaration. * commands.h (Vexecuting_kbd_macro) (Vminibuffer_local_completion_map) (Vminibuffer_local_filename_completion_map) (Vminibuffer_local_filename_must_match_map) (Vminibuffer_local_map, Vminibuffer_local_must_match_map) (Vminibuffer_local_ns_map, Vthis_command) (Vunread_command_events, cursor_in_echo_area) (last_command_event, last_nonmenu_event, unread_command_char): Remove declaration. * coding.h (Vcoding_system_for_read, Vcoding_system_for_write) (Vdefault_file_name_coding_system) (Vdefault_process_coding_system, Vfile_name_coding_system) (Vlast_coding_system_used, Vlocale_coding_system) (Vselect_safe_coding_system_function) (Vtranslation_table_for_input, coding_system_require_warning) (eol_mnemonic_dos, eol_mnemonic_mac, eol_mnemonic_undecided) (eol_mnemonic_unix, inherit_process_coding_system): Remove declaration. * charset.h (Vcharset_list, Vcurrent_iso639_language): Remove declaration. * character.h (Vauto_fill_chars, Vchar_direction_table) (Vchar_script_table, Vchar_width_table, Vprintable_chars) (Vscript_representative_chars, Vtranslation_table_vector) (Vunicode_category_table): Remove declaration. * ccl.h (Vfont_ccl_encoder_alist): Remove declaration. * buffer.h (Vafter_change_functions, Vbefore_change_functions) (Vdeactivate_mark, Vfirst_change_hook, Vtransient_mark_mode) (inhibit_modification_hooks): Remove declaration. * xterm.c (syms_of_xterm): Update. (Vx_alt_keysym, Vx_hyper_keysym, Vx_keysym_table) (Vx_meta_keysym, Vx_super_keysym, Vx_toolkit_scroll_bars) (x_mouse_click_focus_ignore_position) (x_underline_at_descent_line) (x_use_underline_position_properties): Remove. * xsmfns.c (syms_of_xsmfns): Update. (Vx_session_id, Vx_session_previous_id): Remove. * xsettings.c (syms_of_xsettings): Update. (Vxft_settings, use_system_font): Remove. * xselect.c (syms_of_xselect): Update. (Vselection_converter_alist, Vx_lost_selection_functions) (Vx_sent_selection_functions, x_selection_timeout): Remove. * xfns.c (syms_of_xfns): Update. (Vgtk_version_string, Vmotif_version_string) (Vx_cursor_fore_pixel, Vx_hourglass_pointer_shape) (Vx_max_tooltip_size, Vx_mode_pointer_shape) (Vx_no_window_manager, Vx_nontext_pointer_shape) (Vx_pixel_size_width_font_regexp, Vx_pointer_shape) (Vx_sensitive_text_pointer_shape) (Vx_window_horizontal_drag_shape, x_gtk_file_dialog_help_text) (x_gtk_show_hidden_files, x_gtk_use_old_file_dialog) (x_gtk_use_system_tooltips, x_gtk_whole_detached_tool_bar): Remove. * xfaces.c (syms_of_xfaces): Update. (Vface_default_stipple, Vface_font_rescale_alist) (Vface_ignored_fonts, Vface_new_frame_defaults) (Vface_remapping_alist, Vfont_list_limit) (Vscalable_fonts_allowed, Vtty_defined_color_alist): Remove. * xdisp.c (syms_of_xdisp): Update. (Vauto_resize_tool_bars, Vblink_cursor_alist) (Vdisplay_pixels_per_inch, Vfontification_functions) (Vframe_title_format, Vglobal_mode_string) (Vglyphless_char_display, Vhourglass_delay, Vhscroll_step) (Vicon_title_format, Vinhibit_redisplay) (Vline_number_display_limit, Vline_prefix) (Vmax_mini_window_height, Vmenu_bar_update_hook) (Vmenu_updating_frame, Vmessage_log_max) (Vmouse_autoselect_window, Vnobreak_char_display) (Voverlay_arrow_position, Voverlay_arrow_string) (Voverlay_arrow_variable_list, Vredisplay_end_trigger_functions) (Vresize_mini_windows, Vshow_trailing_whitespace) (Vtool_bar_border, Vtool_bar_button_margin, Vtool_bar_style) (Vtruncate_partial_width_windows, Vvoid_text_area_pointer) (Vwindow_scroll_functions, Vwindow_size_change_functions) (Vwindow_text_change_functions, Vwrap_prefix) (auto_raise_tool_bar_buttons_p, automatic_hscrolling_p) (debug_end_pos, display_hourglass_p, emacs_scroll_step) (highlight_nonselected_windows, hscroll_margin) (inhibit_eval_during_redisplay, inhibit_free_realized_faces) (inhibit_menubar_update, inhibit_try_cursor_movement) (inhibit_try_window_id, inhibit_try_window_reusing) (line_number_display_limit_width) (make_cursor_line_fully_visible_p, message_truncate_lines) (mode_line_inverse_video, multiple_frames, overline_margin) (scroll_conservatively, scroll_margin, tool_bar_button_relief) (tool_bar_max_label_size, underline_minimum_offset) (unibyte_display_via_language_environment, x_stretch_cursor_p): Remove. * window.c (syms_of_window): Update. (Vminibuf_scroll_window, Vother_window_scroll_buffer) (Vrecenter_redisplay, Vscroll_preserve_screen_position) (Vtemp_buffer_show_function, Vwindow_configuration_change_hook) (Vwindow_point_insertion_type, auto_window_vscroll_p) (mode_line_in_non_selected_windows, next_screen_context_lines) (window_min_height, window_min_width): Remove. (scroll_margin): Remove declaration. * w32term.c (syms_of_w32term): Update. (Vw32_capslock_is_shiftlock, Vw32_grab_focus_on_raise) (Vw32_recognize_altgr, Vw32_swap_mouse_buttons) (Vx_toolkit_scroll_bars, w32_num_mouse_buttons) (w32_use_visible_system_caret, x_underline_at_descent_line) (x_use_underline_position_properties): Remove. (Vcommand_line_args, Vsystem_name, extra_keyboard_modifiers): Remove declaration. * w32select.c (syms_of_w32select): Update. (Vnext_selection_coding_system, Vselection_coding_system): Remove. * w32proc.c (syms_of_ntproc): Update. (Vw32_downcase_file_names, Vw32_generate_fake_inodes) (Vw32_get_true_file_attributes, Vw32_quote_process_args) (Vw32_start_process_inherit_error_mode) (Vw32_start_process_share_console) (Vw32_start_process_show_window, w32_pipe_read_delay): Remove. (Vsystem_name): Remove declaration. * w32font.c (syms_of_w32font): Update. (Vw32_charset_info_alist): Remove. * w32fns.c (globals_of_w32fns, syms_of_w32fns): Update. (Vw32_alt_is_meta, Vw32_apps_modifier, Vw32_bdf_filename_alist) (Vw32_color_map, Vw32_enable_caps_lock, Vw32_enable_num_lock) (Vw32_enable_palette, Vw32_lwindow_modifier) (Vw32_pass_alt_to_system, Vw32_pass_lwindow_to_system) (Vw32_pass_rwindow_to_system, Vw32_phantom_key_code) (Vw32_rwindow_modifier, Vw32_scroll_lock_modifier) (Vx_cursor_fore_pixel, Vx_hourglass_pointer_shape) (Vx_max_tooltip_size, Vx_mode_pointer_shape) (Vx_no_window_manager, Vx_nontext_pointer_shape) (Vx_pixel_size_width_font_regexp, Vx_pointer_shape) (Vx_sensitive_text_pointer_shape) (Vx_window_horizontal_drag_shape, w32_ansi_code_page) (w32_enable_synthesized_fonts, w32_mouse_button_tolerance) (w32_mouse_move_interval) (w32_pass_extra_mouse_buttons_to_system) (w32_pass_multimedia_buttons_to_system, w32_quit_key) (w32_strict_fontnames, w32_strict_painting): Remove. (Vhourglass_delay, Vmenu_bar_mode, Vtool_bar_mode) (Vw32_recognize_altgr, Vwindow_system_version) (w32_num_mouse_buttons, w32_use_visible_system_caret): Remove declaration. * w32console.c (syms_of_ntterm): Update. (w32_use_full_screen_buffer): Remove. (Vtty_defined_color_alist): Remove declaration. * w16select.c (syms_of_win16select): Update. (Vnext_selection_coding_system, Vselection_coding_system): Remove. * undo.c (syms_of_undo): Update. (Vundo_outer_limit, Vundo_outer_limit_function) (undo_inhibit_record_point, undo_limit, undo_strong_limit): Remove. * textprop.c (syms_of_textprop): Update. (Vchar_property_alias_alist, Vdefault_text_properties) (Vinhibit_point_motion_hooks, Vtext_property_default_nonsticky): Remove. * terminal.c (syms_of_terminal): Update. (Vdelete_terminal_functions, Vring_bell_function): Remove. * term.c (syms_of_term): Update. (Vresume_tty_functions, Vsuspend_tty_functions) (no_redraw_on_reenter, system_uses_terminfo, visible_cursor): Remove. * syntax.c (syms_of_syntax): Update. (Vfind_word_boundary_function_table, multibyte_syntax_as_symbol) (open_paren_in_column_0_is_defun_start) (parse_sexp_ignore_comments, parse_sexp_lookup_properties) (words_include_escapes): Remove. * search.c (syms_of_search): Update. (Vinhibit_changing_match_data, Vsearch_spaces_regexp): Remove. * process.c (syms_of_process): Update. (Vprocess_adaptive_read_buffering, Vprocess_connection_type) (delete_exited_processes): Remove. * print.c (syms_of_print): Update. (Vfloat_output_format, Vprint_charset_text_property) (Vprint_circle, Vprint_continuous_numbering, Vprint_gensym) (Vprint_length, Vprint_level, Vprint_number_table) (Vstandard_output, print_escape_multibyte) (print_escape_newlines, print_escape_nonascii, print_quoted): Remove. * msdos.c (syms_of_msdos): Update. (Vdos_unsupported_char_glyph): Remove. (unibyte_display_via_language_environment): Remove declaration. * minibuf.c (syms_of_minibuf): Update. (Vcompletion_regexp_list, Vhistory_add_new_input) (Vhistory_length, Vminibuffer_completing_file_name) (Vminibuffer_completion_confirm) (Vminibuffer_completion_predicate, Vminibuffer_completion_table) (Vminibuffer_exit_hook, Vminibuffer_help_form) (Vminibuffer_history_position, Vminibuffer_history_variable) (Vminibuffer_prompt_properties, Vminibuffer_setup_hook) (Vread_buffer_function, Vread_expression_map) (completion_ignore_case, enable_recursive_minibuffers) (history_delete_duplicates, minibuffer_allow_text_properties) (minibuffer_auto_raise, read_buffer_completion_ignore_case): Remove. * marker.c (syms_of_marker): Update. (byte_debug_flag): Remove. * macros.c (syms_of_macros): Update. (Vexecuting_kbd_macro, executing_kbd_macro_index): Remove. * lread.c (syms_of_lread): Update. (Vafter_load_alist, Vbyte_boolean_vars) (Vbytecomp_version_regexp, Vcurrent_load_list) (Veval_buffer_list, Vload_file_name, Vload_file_rep_suffixes) (Vload_history, Vload_path, Vload_read_function) (Vload_source_file_function, Vload_suffixes, Vobarray) (Vold_style_backquotes, Vpreloaded_file_list, Vread_circle) (Vread_symbol_positions_list, Vread_with_symbol_positions) (Vsource_directory, Vstandard_input, Vuser_init_file, Vvalues) (force_load_messages, load_convert_to_unibyte) (load_dangerous_libraries, load_force_doc_strings) (load_in_progress): Remove. * keymap.c (syms_of_keymap): Update. (Vdefine_key_rebound_commands, Vemulation_mode_map_alists) (Vminibuffer_local_completion_map) (Vminibuffer_local_filename_completion_map) (Vminibuffer_local_filename_must_match_map) (Vminibuffer_local_map, Vminibuffer_local_must_match_map) (Vminibuffer_local_ns_map, Vminor_mode_map_alist) (Vminor_mode_overriding_map_alist, Vwhere_is_preferred_modifier): Remove. * keyboard.c (syms_of_keyboard): Update. (Vauto_save_timeout, Vcommand_error_function) (Vcommand_hook_internal, Vdeactivate_mark) (Vdeferred_action_function, Vdeferred_action_list) (Vdisable_point_adjustment, Vdouble_click_time) (Vecho_keystrokes, Venable_disabled_menus_and_buttons) (Vfunction_key_map, Vglobal_disable_point_adjustment) (Vhelp_char, Vhelp_event_list, Vhelp_form) (Vinput_method_function, Vinput_method_previous_message) (Vkey_translation_map, Vlast_event_frame) (Vlucid_menu_bar_dirty_flag, Vmenu_bar_final_items) (Vminibuffer_message_timeout, Voverriding_local_map) (Voverriding_local_map_menu_flag, Vpost_command_hook) (Vpre_command_hook, Vprefix_help_command) (Vsaved_region_selection, Vselect_active_regions) (Vshow_help_function, Vspecial_event_map, Vsuggest_key_bindings) (Vthis_command, Vthis_command_keys_shift_translated) (Vthis_original_command, Vthrow_on_input, Vtimer_idle_list) (Vtimer_list, Vtool_bar_separator_image_expression, Vtop_level) (Vtty_erase_char, Vunread_command_events) (Vunread_input_method_events, Vunread_post_input_method_events) (auto_save_interval, cannot_suspend, do_mouse_tracking) (double_click_fuzz, extra_keyboard_modifiers) (inhibit_local_menu_bar_menus, last_command_event) (last_input_event, last_nonmenu_event, menu_prompt_more_char) (menu_prompting, meta_prefix_char, num_input_keys) (num_nonmacro_input_events, polling_period, unread_command_char): Remove. * insdel.c (syms_of_insdel): Update. (Vcombine_after_change_calls, check_markers_debug_flag): Remove. * indent.c (syms_of_indent): Update. (indent_tabs_mode): Remove. * image.c (syms_of_image): Update. (Vimage_cache_eviction_delay, Vimage_types) (Vimagemagick_render_type, Vmax_image_size, Vx_bitmap_file_path) (cross_disabled_images): Remove. * fringe.c (syms_of_fringe): Update. (Vfringe_bitmaps, Voverflow_newline_into_fringe): Remove. * frame.c (syms_of_frame): Update. (Vdefault_frame_alist, Vdefault_frame_scroll_bars) (Vdelete_frame_functions, Vframe_alpha_lower_limit) (Vmake_pointer_invisible, Vmenu_bar_mode, Vmouse_highlight) (Vmouse_position_function, Vterminal_frame, Vtool_bar_mode) (Vx_resource_class, Vx_resource_name, focus_follows_mouse): Remove. * fontset.c (syms_of_fontset): Update. (Valternate_fontname_alist, Vfont_encoding_charset_alist) (Vfontset_alias_alist, Vignore_relative_composition) (Votf_script_alist, Vuse_default_ascent) (Vvertical_centering_font_regexp): Remove. * font.c (syms_of_font): Update. (Vfont_encoding_alist, Vfont_log, Vfont_slant_table) (Vfont_weight_table, Vfont_width_table): Remove. * fns.c (syms_of_fns): Update. (Vfeatures, use_dialog_box, use_file_dialog): Remove. * filelock.c (syms_of_filelock): Update. (Vtemporary_file_directory): Remove. * fileio.c (syms_of_fileio): Update. (Vafter_insert_file_functions, Vauto_save_include_big_deletions) (Vauto_save_list_file_name, Vauto_save_visited_file_name) (Vdefault_file_name_coding_system, Vfile_name_coding_system) (Vfile_name_handler_alist, Vinhibit_file_name_handlers) (Vinhibit_file_name_operation, Vset_auto_coding_function) (Vwrite_region_annotate_functions) (Vwrite_region_annotations_so_far) (Vwrite_region_post_annotation_function) (delete_by_moving_to_trash, write_region_inhibit_fsync): Remove. (Vw32_get_true_file_attributes): Remove declaration. * eval.c (syms_of_eval): Update. (Vdebug_ignored_errors, Vdebug_on_error, Vdebug_on_signal) (Vdebugger, Vinhibit_quit, Vmacro_declaration_function) (Vquit_flag, Vsignal_hook_function, Vstack_trace_on_error) (debug_on_next_call, debug_on_quit, debugger_may_continue) (max_lisp_eval_depth, max_specpdl_size): Remove. * emacs.c (syms_of_emacs): Update. (Vafter_init_time, Vbefore_init_time, Vcommand_line_args) (Vdynamic_library_alist, Vemacs_copyright, Vemacs_version) (Vinstallation_directory, Vinvocation_directory) (Vinvocation_name, Vkill_emacs_hook, Vpath_separator) (Vprevious_system_messages_locale, Vprevious_system_time_locale) (Vsystem_configuration, Vsystem_configuration_options) (Vsystem_messages_locale, Vsystem_time_locale, Vsystem_type) (inhibit_x_resources, noninteractive1): Remove. * editfns.c (syms_of_editfns): Update. (Vbuffer_access_fontified_property) (Vbuffer_access_fontify_functions, Vinhibit_field_text_motion) (Voperating_system_release, Vsystem_name, Vuser_full_name) (Vuser_login_name, Vuser_real_login_name): Remove. * dosfns.c (syms_of_dosfns): Update. (Vdos_display_scancodes, Vdos_version, Vdos_windows_version) (dos_codepage, dos_country_code, dos_decimal_point) (dos_hyper_key, dos_keyboard_layout, dos_keypad_mode) (dos_super_key, dos_timezone_offset): Remove. * doc.c (syms_of_doc): Update. (Vbuild_files, Vdoc_file_name): Remove. * dispnew.c (syms_of_display): Update. (Vglyph_table, Vinitial_window_system) (Vredisplay_preemption_period, Vstandard_display_table) (Vwindow_system_version, baud_rate, cursor_in_echo_area) (inverse_video, redisplay_dont_pause, visible_bell): Remove. * dired.c (syms_of_dired): Update. (Vcompletion_ignored_extensions): Remove. (Vw32_get_true_file_attributes): Remove declaration. * dbusbind.c (syms_of_dbusbind): Update. (Vdbus_debug, Vdbus_registered_buses) (Vdbus_registered_objects_table): Remove. * data.c (syms_of_data): Update. (Vmost_negative_fixnum, Vmost_positive_fixnum): Remove. * composite.c (syms_of_composite): Update. (Vauto_composition_function, Vauto_composition_mode) (Vcompose_chars_after_function, Vcomposition_function_table): Remove. * coding.c (syms_of_coding): Update. (Vcharset_revision_table, Vcoding_category_list) (Vcoding_system_alist, Vcoding_system_for_read) (Vcoding_system_for_write, Vcoding_system_list) (Vdefault_process_coding_system, Venable_character_translation) (Vfile_coding_system_alist, Vlast_code_conversion_error) (Vlast_coding_system_used, Vlatin_extra_code_table) (Vlocale_coding_system, Vnetwork_coding_system_alist) (Vprocess_coding_system_alist) (Vselect_safe_coding_system_function) (Vstandard_translation_table_for_decode) (Vstandard_translation_table_for_encode) (Vtranslation_table_for_input, coding_system_require_warning) (eol_mnemonic_dos, eol_mnemonic_mac, eol_mnemonic_undecided) (eol_mnemonic_unix, inherit_process_coding_system) (inhibit_eol_conversion, inhibit_iso_escape_detection) (inhibit_null_byte_detection): Remove. * cmds.c (syms_of_cmds): Update. (Vpost_self_insert_hook): Remove. * charset.c (syms_of_charset): Update. (Vcharset_list, Vcharset_map_path, Vcurrent_iso639_language) (inhibit_load_charset_map): Remove. * character.c (syms_of_character): Update. (Vauto_fill_chars, Vchar_direction_table, Vchar_script_table) (Vchar_width_table, Vprintable_chars) (Vscript_representative_chars, Vtranslation_table_vector) (Vunicode_category_table): Remove. * ccl.c (syms_of_ccl): Update. (Vcode_conversion_map_vector, Vfont_ccl_encoder_alist) (Vtranslation_hash_table_vector): Remove. * category.c (syms_of_category): Update. (Vword_combining_categories, Vword_separating_categories): Remove. * callproc.c (syms_of_callproc): Update. (Vconfigure_info_directory, Vdata_directory, Vdoc_directory) (Vexec_directory, Vexec_path, Vexec_suffixes) (Vinitial_environment, Vprocess_environment) (Vshared_game_score_directory, Vshell_file_name): Remove. * callint.c (syms_of_callint): Update. (Vcommand_debug_status, Vcommand_history, Vcurrent_prefix_arg) (Vmark_even_if_inactive, Vmouse_leave_buffer_hook): Remove. * bytecode.c (syms_of_bytecode): Update. (Vbyte_code_meter, byte_metering_on): Remove. * buffer.c (syms_of_buffer): Update. (Vafter_change_functions, Vbefore_change_functions) (Vchange_major_mode_hook, Vfirst_change_hook) (Vinhibit_read_only, Vkill_buffer_query_functions) (Vtransient_mark_mode, inhibit_modification_hooks): Remove. * alloc.c (syms_of_alloc): Update. (Vgc_cons_percentage, Vgc_elapsed, Vmemory_full) (Vmemory_signal_data, Vpost_gc_hook, Vpurify_flag) (cons_cells_consed, floats_consed, garbage_collection_messages) (gc_cons_threshold, gcs_done, intervals_consed) (misc_objects_consed, pure_bytes_used, string_chars_consed) (strings_consed, symbols_consed, vector_cells_consed): Remove. * lisp.h (DEFVAR_LISP, DEFVAR_LISP_NOPRO, DEFVAR_BOOL) (DEFVAR_INT): Assume global is in `globals'. * alloc.c (globals): Define.
author Tom Tromey <tromey@redhat.com>
date Tue, 18 Jan 2011 13:45:37 -0700
parents ef719132ddfa
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13337
84acc3adcd63 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 13334
diff changeset
1 ;;; tmm.el --- text mode access to menu-bar
10955
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2
64762
41bb365f41c4 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64091
diff changeset
3 ;; Copyright (C) 1994, 1995, 1996, 2000, 2001, 2002, 2003,
112218
376148b31b5e Add 2011 to FSF/AIST copyright years.
Glenn Morris <rgm@gnu.org>
parents: 108497
diff changeset
4 ;; 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
10955
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6 ;; Author: Ilya Zakharevich <ilya@math.mps.ohio-state.edu>
13334
c55f17d3931f (tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents: 12960
diff changeset
7 ;; Maintainer: FSF
42991
2cc71fdee37e (tmm-get-keymap): Honour :visible in `menu-item'.
Pavel Janík <Pavel@Janik.cz>
parents: 41483
diff changeset
8 ;; Keywords: convenience
10955
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9
10956
40810ac8d212 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 10955
diff changeset
10 ;; This file is part of GNU Emacs.
10955
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94088
diff changeset
12 ;; GNU Emacs is free software: you can redistribute it and/or modify
10955
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 ;; it under the terms of the GNU General Public License as published by
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94088
diff changeset
14 ;; the Free Software Foundation, either version 3 of the License, or
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94088
diff changeset
15 ;; (at your option) any later version.
10955
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 ;; GNU General Public License for more details.
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94088
diff changeset
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
10955
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14120
diff changeset
25 ;;; Commentary:
10955
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26
42991
2cc71fdee37e (tmm-get-keymap): Honour :visible in `menu-item'.
Pavel Janík <Pavel@Janik.cz>
parents: 41483
diff changeset
27 ;; This package provides text mode access to the menu bar.
10955
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14120
diff changeset
29 ;;; Code:
10955
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31 (require 'electric)
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32
21088
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 19505
diff changeset
33 (defgroup tmm nil
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 19505
diff changeset
34 "Text mode access to menu-bar."
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 19505
diff changeset
35 :prefix "tmm-"
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 19505
diff changeset
36 :group 'menu)
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 19505
diff changeset
37
10955
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38 ;;; The following will be localized, added only to pacify the compiler.
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39 (defvar tmm-short-cuts)
13334
c55f17d3931f (tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents: 12960
diff changeset
40 (defvar tmm-old-mb-map nil)
10955
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 (defvar tmm-old-comp-map)
76905
624ef730616c (tmm-c-prompt): Initialize.
Nick Roberts <nickrob@snap.net.nz>
parents: 76802
diff changeset
42 (defvar tmm-c-prompt nil)
10955
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43 (defvar tmm-km-list)
16040
74fc923ff6d5 (tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents: 15564
diff changeset
44 (defvar tmm-next-shortcut-digit)
10955
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45 (defvar tmm-table-undef)
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46
12960
6db607a7b62d Fix typo in global-map define.
Richard M. Stallman <rms@gnu.org>
parents: 12763
diff changeset
47 ;;;###autoload (define-key global-map "\M-`" 'tmm-menubar)
13915
1319e4b9aa6c (tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents: 13581
diff changeset
48 ;;;###autoload (define-key global-map [menu-bar mouse-1] 'tmm-menubar-mouse)
12763
b8e986069a58 Don't alter bindings in minibuffer-local-must-match-map
Richard M. Stallman <rms@gnu.org>
parents: 10956
diff changeset
49
10955
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50 ;;;###autoload
13915
1319e4b9aa6c (tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents: 13581
diff changeset
51 (defun tmm-menubar (&optional x-position)
10955
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52 "Text-mode emulation of looking and choosing from a menubar.
13915
1319e4b9aa6c (tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents: 13581
diff changeset
53 See the documentation for `tmm-prompt'.
1319e4b9aa6c (tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents: 13581
diff changeset
54 X-POSITION, if non-nil, specifies a horizontal position within the menu bar;
1319e4b9aa6c (tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents: 13581
diff changeset
55 we make that menu bar item (the one at that position) the default choice."
10955
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 (interactive)
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 (run-hooks 'menu-bar-update-hook)
13334
c55f17d3931f (tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents: 12960
diff changeset
58 ;; Obey menu-bar-final-items; put those items last.
13915
1319e4b9aa6c (tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents: 13581
diff changeset
59 (let ((menu-bar (tmm-get-keybind [menu-bar]))
1319e4b9aa6c (tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents: 13581
diff changeset
60 menu-bar-item)
13334
c55f17d3931f (tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents: 12960
diff changeset
61 (let ((list menu-bar-final-items))
c55f17d3931f (tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents: 12960
diff changeset
62 (while list
c55f17d3931f (tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents: 12960
diff changeset
63 (let ((item (car list)))
c55f17d3931f (tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents: 12960
diff changeset
64 ;; ITEM is the name of an item that we want to put last.
c55f17d3931f (tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents: 12960
diff changeset
65 ;; Find it in MENU-BAR and move it to the end.
c55f17d3931f (tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents: 12960
diff changeset
66 (let ((this-one (assq item menu-bar)))
c55f17d3931f (tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents: 12960
diff changeset
67 (setq menu-bar (append (delq this-one menu-bar)
c55f17d3931f (tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents: 12960
diff changeset
68 (list this-one)))))
c55f17d3931f (tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents: 12960
diff changeset
69 (setq list (cdr list))))
13915
1319e4b9aa6c (tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents: 13581
diff changeset
70 (if x-position
76905
624ef730616c (tmm-c-prompt): Initialize.
Nick Roberts <nickrob@snap.net.nz>
parents: 76802
diff changeset
71 (let ((tail menu-bar) (column 0)
76911
0d761d6b0064 (tmm-menubar, tmm-prompt): Handle visibility of top level menu-items.
Nick Roberts <nickrob@snap.net.nz>
parents: 76905
diff changeset
72 this-one name visible)
76802
293d8ec25f85 (tmm-menubar): Select the right menu item with the mouse.
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
73 (while (and tail (<= column x-position))
13915
1319e4b9aa6c (tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents: 13581
diff changeset
74 (setq this-one (car tail))
76802
293d8ec25f85 (tmm-menubar): Select the right menu item with the mouse.
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
75 (if (and (consp this-one)
293d8ec25f85 (tmm-menubar): Select the right menu item with the mouse.
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
76 (consp (cdr this-one))
76911
0d761d6b0064 (tmm-menubar, tmm-prompt): Handle visibility of top level menu-items.
Nick Roberts <nickrob@snap.net.nz>
parents: 76905
diff changeset
77 (setq name ;simple menu
76905
624ef730616c (tmm-c-prompt): Initialize.
Nick Roberts <nickrob@snap.net.nz>
parents: 76802
diff changeset
78 (cond ((stringp (nth 1 this-one))
624ef730616c (tmm-c-prompt): Initialize.
Nick Roberts <nickrob@snap.net.nz>
parents: 76802
diff changeset
79 (nth 1 this-one))
76911
0d761d6b0064 (tmm-menubar, tmm-prompt): Handle visibility of top level menu-items.
Nick Roberts <nickrob@snap.net.nz>
parents: 76905
diff changeset
80 ;extended menu
0d761d6b0064 (tmm-menubar, tmm-prompt): Handle visibility of top level menu-items.
Nick Roberts <nickrob@snap.net.nz>
parents: 76905
diff changeset
81 ((stringp (nth 2 this-one))
0d761d6b0064 (tmm-menubar, tmm-prompt): Handle visibility of top level menu-items.
Nick Roberts <nickrob@snap.net.nz>
parents: 76905
diff changeset
82 (setq visible (plist-get
0d761d6b0064 (tmm-menubar, tmm-prompt): Handle visibility of top level menu-items.
Nick Roberts <nickrob@snap.net.nz>
parents: 76905
diff changeset
83 (nthcdr 4 this-one) :visible))
0d761d6b0064 (tmm-menubar, tmm-prompt): Handle visibility of top level menu-items.
Nick Roberts <nickrob@snap.net.nz>
parents: 76905
diff changeset
84 (unless (and visible (not (eval visible)))
0d761d6b0064 (tmm-menubar, tmm-prompt): Handle visibility of top level menu-items.
Nick Roberts <nickrob@snap.net.nz>
parents: 76905
diff changeset
85 (nth 2 this-one))))))
76905
624ef730616c (tmm-c-prompt): Initialize.
Nick Roberts <nickrob@snap.net.nz>
parents: 76802
diff changeset
86 (setq column (+ column (length name) 1)))
13915
1319e4b9aa6c (tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents: 13581
diff changeset
87 (setq tail (cdr tail)))
1319e4b9aa6c (tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents: 13581
diff changeset
88 (setq menu-bar-item (car this-one))))
1319e4b9aa6c (tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents: 13581
diff changeset
89 (tmm-prompt menu-bar nil menu-bar-item)))
1319e4b9aa6c (tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents: 13581
diff changeset
90
14120
4d4eb72a8d65 (tmm-menubar-mouse): Add autoload cookie.
Karl Heuer <kwzh@gnu.org>
parents: 14011
diff changeset
91 ;;;###autoload
13915
1319e4b9aa6c (tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents: 13581
diff changeset
92 (defun tmm-menubar-mouse (event)
1319e4b9aa6c (tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents: 13581
diff changeset
93 "Text-mode emulation of looking and choosing from a menubar.
1319e4b9aa6c (tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents: 13581
diff changeset
94 This command is used when you click the mouse in the menubar
1319e4b9aa6c (tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents: 13581
diff changeset
95 on a console which has no window system but does have a mouse.
1319e4b9aa6c (tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents: 13581
diff changeset
96 See the documentation for `tmm-prompt'."
1319e4b9aa6c (tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents: 13581
diff changeset
97 (interactive "e")
1319e4b9aa6c (tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents: 13581
diff changeset
98 (tmm-menubar (car (posn-x-y (event-start event)))))
10955
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99
21088
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 19505
diff changeset
100 (defcustom tmm-mid-prompt "==>"
84430
490362706869 Remove spurious * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 83648
diff changeset
101 "String to insert between shortcut and menu item.
16040
74fc923ff6d5 (tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents: 15564
diff changeset
102 If nil, there will be no shortcuts. It should not consist only of spaces,
21088
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 19505
diff changeset
103 or else the correct item might not be found in the `*Completions*' buffer."
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 19505
diff changeset
104 :type 'string
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 19505
diff changeset
105 :group 'tmm)
10955
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107 (defvar tmm-mb-map nil
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108 "A place to store minibuffer map.")
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109
42991
2cc71fdee37e (tmm-get-keymap): Honour :visible in `menu-item'.
Pavel Janík <Pavel@Janik.cz>
parents: 41483
diff changeset
110 (defcustom tmm-completion-prompt
44742
bf788fcf5b82 (tmm-completion-prompt): Doc fix.
Pavel Janík <Pavel@Janik.cz>
parents: 42991
diff changeset
111 "Press PageUp key to reach this buffer from the minibuffer.
10955
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112 Alternatively, you can use Up/Down keys (or your History keys) to change
42991
2cc71fdee37e (tmm-get-keymap): Honour :visible in `menu-item'.
Pavel Janík <Pavel@Janik.cz>
parents: 41483
diff changeset
113 the item in the minibuffer, and press RET when you are done, or press the
13533
d081e1969406 (tmm-define-keys): Don't define ESC ESC.
Richard M. Stallman <rms@gnu.org>
parents: 13499
diff changeset
114 marked letters to pick up your choice. Type C-g or ESC ESC ESC to cancel.
10955
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115 "
84430
490362706869 Remove spurious * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 83648
diff changeset
116 "Help text to insert on the top of the completion buffer.
16040
74fc923ff6d5 (tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents: 15564
diff changeset
117 To save space, you can set this to nil,
21088
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 19505
diff changeset
118 in which case the standard introduction text is deleted too."
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 19505
diff changeset
119 :type '(choice string (const nil))
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 19505
diff changeset
120 :group 'tmm)
16040
74fc923ff6d5 (tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents: 15564
diff changeset
121
21088
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 19505
diff changeset
122 (defcustom tmm-shortcut-style '(downcase upcase)
84430
490362706869 Remove spurious * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 83648
diff changeset
123 "What letters to use as menu shortcuts.
42991
2cc71fdee37e (tmm-get-keymap): Honour :visible in `menu-item'.
Pavel Janík <Pavel@Janik.cz>
parents: 41483
diff changeset
124 Must be either one of the symbols `downcase' or `upcase',
21088
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 19505
diff changeset
125 or else a list of the two in the order you prefer."
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 19505
diff changeset
126 :type '(choice (const downcase)
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 19505
diff changeset
127 (const upcase)
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 19505
diff changeset
128 (repeat (choice (const downcase) (const upcase))))
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 19505
diff changeset
129 :group 'tmm)
16040
74fc923ff6d5 (tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents: 15564
diff changeset
130
21088
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 19505
diff changeset
131 (defcustom tmm-shortcut-words 2
84430
490362706869 Remove spurious * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 83648
diff changeset
132 "How many successive words to try for shortcuts, nil means all.
42991
2cc71fdee37e (tmm-get-keymap): Honour :visible in `menu-item'.
Pavel Janík <Pavel@Janik.cz>
parents: 41483
diff changeset
133 If you use only one of `downcase' or `upcase' for `tmm-shortcut-style',
21088
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 19505
diff changeset
134 specify nil for this variable."
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 19505
diff changeset
135 :type '(choice integer (const nil))
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 19505
diff changeset
136 :group 'tmm)
10955
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137
63082
24720eb84061 (tmm-inactive, tmm-remove-inactive-mouse-face):
Juri Linkov <juri@jurta.org>
parents: 63054
diff changeset
138 (defface tmm-inactive
63054
bb05eaafc76a * tmm.el (tmm-inactive-face): Inherit from `shadow' face.
Juri Linkov <juri@jurta.org>
parents: 62972
diff changeset
139 '((t :inherit shadow))
62972
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
140 "Face used for inactive menu items."
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
141 :group 'tmm)
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
142
10955
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143 ;;;###autoload
13916
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
144 (defun tmm-prompt (menu &optional in-popup default-item)
10955
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145 "Text-mode emulation of calling the bindings in keymap.
13915
1319e4b9aa6c (tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents: 13581
diff changeset
146 Creates a text-mode menu of possible choices. You can access the elements
1319e4b9aa6c (tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents: 13581
diff changeset
147 in the menu in two ways:
1319e4b9aa6c (tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents: 13581
diff changeset
148 *) via history mechanism from minibuffer;
10955
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 *) Or via completion-buffer that is automatically shown.
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150 The last alternative is currently a hack, you cannot use mouse reliably.
13916
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
151
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
152 MENU is like the MENU argument to `x-popup-menu': either a
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
153 keymap or an alist of alists.
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
154 DEFAULT-ITEM, if non-nil, specifies an initial default choice.
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
155 Its value should be an event that has a binding in MENU."
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
156 ;; If the optional argument IN-POPUP is t,
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
157 ;; then MENU is an alist of elements of the form (STRING . VALUE).
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
158 ;; That is used for recursive calls only.
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
159 (let ((gl-str "Menu bar") ;; The menu bar itself is not a menu keymap
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
160 ; so it doesn't have a name.
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
161 tmm-km-list out history history-len tmm-table-undef tmm-c-prompt
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
162 tmm-old-mb-map tmm-old-comp-map tmm-short-cuts
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
163 chosen-string choice
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
164 (not-menu (not (keymapp menu))))
10955
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165 (run-hooks 'activate-menubar-hook)
13916
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
166 ;; Compute tmm-km-list from MENU.
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
167 ;; tmm-km-list is an alist of (STRING . MEANING).
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
168 ;; It has no other elements.
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
169 ;; The order of elements in tmm-km-list is the order of the menu bar.
31675
a8e0d20f0043 Replace mapcar with mapc in several places.
Dave Love <fx@gnu.org>
parents: 29290
diff changeset
170 (mapc (lambda (elt)
112238
4f72b1e43644 Merge from emacs-23 branch.
Glenn Morris <rgm@gnu.org>
parents: 112228
diff changeset
171 (cond
4f72b1e43644 Merge from emacs-23 branch.
Glenn Morris <rgm@gnu.org>
parents: 112228
diff changeset
172 ((stringp elt) (setq gl-str elt))
4f72b1e43644 Merge from emacs-23 branch.
Glenn Morris <rgm@gnu.org>
parents: 112228
diff changeset
173 ((listp elt) (tmm-get-keymap elt not-menu))
4f72b1e43644 Merge from emacs-23 branch.
Glenn Morris <rgm@gnu.org>
parents: 112228
diff changeset
174 ((vectorp elt)
4f72b1e43644 Merge from emacs-23 branch.
Glenn Morris <rgm@gnu.org>
parents: 112228
diff changeset
175 (dotimes (i (length elt))
4f72b1e43644 Merge from emacs-23 branch.
Glenn Morris <rgm@gnu.org>
parents: 112228
diff changeset
176 (tmm-get-keymap (cons i (aref elt i)) not-menu)))))
4f72b1e43644 Merge from emacs-23 branch.
Glenn Morris <rgm@gnu.org>
parents: 112228
diff changeset
177 menu)
13916
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
178 ;; Choose an element of tmm-km-list; put it in choice.
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
179 (if (and not-menu (= 1 (length tmm-km-list)))
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
180 ;; If this is the top-level of an x-popup-menu menu,
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
181 ;; and there is just one pane, choose that one silently.
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
182 ;; This way we only ask the user one question,
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
183 ;; for which element of that pane.
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
184 (setq choice (cdr (car tmm-km-list)))
21688
855aedeb0742 (tmm-get-keymap): Handle new format menu item w/o cache.
Richard M. Stallman <rms@gnu.org>
parents: 21495
diff changeset
185 (unless tmm-km-list
855aedeb0742 (tmm-get-keymap): Handle new format menu item w/o cache.
Richard M. Stallman <rms@gnu.org>
parents: 21495
diff changeset
186 (error "Empty menu reached"))
13916
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
187 (and tmm-km-list
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
188 (let ((index-of-default 0))
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
189 (if tmm-mid-prompt
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
190 (setq tmm-km-list (tmm-add-shortcuts tmm-km-list))
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
191 t)
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
192 ;; Find the default item's index within the menu bar.
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
193 ;; We use this to decide the initial minibuffer contents
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
194 ;; and initial history position.
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
195 (if default-item
76911
0d761d6b0064 (tmm-menubar, tmm-prompt): Handle visibility of top level menu-items.
Nick Roberts <nickrob@snap.net.nz>
parents: 76905
diff changeset
196 (let ((tail menu) visible)
13916
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
197 (while (and tail
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
198 (not (eq (car-safe (car tail)) default-item)))
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
199 ;; Be careful to count only the elements of MENU
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
200 ;; that actually constitute menu bar items.
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
201 (if (and (consp (car tail))
29290
181d214fe71c (tmm-prompt): Recognize menu item definitions of the for
Gerd Moellmann <gerd@gnu.org>
parents: 27350
diff changeset
202 (or (stringp (car-safe (cdr (car tail))))
76911
0d761d6b0064 (tmm-menubar, tmm-prompt): Handle visibility of top level menu-items.
Nick Roberts <nickrob@snap.net.nz>
parents: 76905
diff changeset
203 (and
0d761d6b0064 (tmm-menubar, tmm-prompt): Handle visibility of top level menu-items.
Nick Roberts <nickrob@snap.net.nz>
parents: 76905
diff changeset
204 (eq (car-safe (cdr (car tail))) 'menu-item)
0d761d6b0064 (tmm-menubar, tmm-prompt): Handle visibility of top level menu-items.
Nick Roberts <nickrob@snap.net.nz>
parents: 76905
diff changeset
205 (progn
0d761d6b0064 (tmm-menubar, tmm-prompt): Handle visibility of top level menu-items.
Nick Roberts <nickrob@snap.net.nz>
parents: 76905
diff changeset
206 (setq visible
0d761d6b0064 (tmm-menubar, tmm-prompt): Handle visibility of top level menu-items.
Nick Roberts <nickrob@snap.net.nz>
parents: 76905
diff changeset
207 (plist-get
0d761d6b0064 (tmm-menubar, tmm-prompt): Handle visibility of top level menu-items.
Nick Roberts <nickrob@snap.net.nz>
parents: 76905
diff changeset
208 (nthcdr 4 (car tail)) :visible))
0d761d6b0064 (tmm-menubar, tmm-prompt): Handle visibility of top level menu-items.
Nick Roberts <nickrob@snap.net.nz>
parents: 76905
diff changeset
209 (or (not visible) (eval visible))))))
13916
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
210 (setq index-of-default (1+ index-of-default)))
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
211 (setq tail (cdr tail)))))
62972
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
212 (let ((prompt (concat "^." (regexp-quote tmm-mid-prompt))))
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
213 (setq history
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
214 (reverse (delq nil
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
215 (mapcar
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
216 (lambda (elt)
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
217 (if (string-match prompt (car elt))
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
218 (car elt)))
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
219 tmm-km-list)))))
13916
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
220 (setq history-len (length history))
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
221 (setq history (append history history history history))
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
222 (setq tmm-c-prompt (nth (- history-len 1 index-of-default) history))
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
223 (add-hook 'minibuffer-setup-hook 'tmm-add-prompt)
76802
293d8ec25f85 (tmm-menubar): Select the right menu item with the mouse.
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
224 (if default-item
293d8ec25f85 (tmm-menubar): Select the right menu item with the mouse.
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
225 (setq out (car (nth index-of-default tmm-km-list)))
293d8ec25f85 (tmm-menubar): Select the right menu item with the mouse.
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
226 (save-excursion
293d8ec25f85 (tmm-menubar): Select the right menu item with the mouse.
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
227 (unwind-protect
293d8ec25f85 (tmm-menubar): Select the right menu item with the mouse.
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
228 (setq out
293d8ec25f85 (tmm-menubar): Select the right menu item with the mouse.
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
229 (completing-read
293d8ec25f85 (tmm-menubar): Select the right menu item with the mouse.
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
230 (concat gl-str
293d8ec25f85 (tmm-menubar): Select the right menu item with the mouse.
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
231 " (up/down to change, PgUp to menu): ")
293d8ec25f85 (tmm-menubar): Select the right menu item with the mouse.
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
232 tmm-km-list nil t nil
293d8ec25f85 (tmm-menubar): Select the right menu item with the mouse.
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
233 (cons 'history
293d8ec25f85 (tmm-menubar): Select the right menu item with the mouse.
Nick Roberts <nickrob@snap.net.nz>
parents: 75347
diff changeset
234 (- (* 2 history-len) index-of-default))))
84430
490362706869 Remove spurious * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 83648
diff changeset
235 (remove-hook 'minibuffer-setup-hook 'tmm-add-prompt)
490362706869 Remove spurious * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 83648
diff changeset
236 (if (get-buffer "*Completions*")
490362706869 Remove spurious * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 83648
diff changeset
237 (with-current-buffer "*Completions*"
490362706869 Remove spurious * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 83648
diff changeset
238 (use-local-map tmm-old-comp-map)
490362706869 Remove spurious * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 83648
diff changeset
239 (bury-buffer (current-buffer)))))))))
13916
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
240 (setq choice (cdr (assoc out tmm-km-list)))
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
241 (and (null choice)
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
242 (> (length out) (length tmm-c-prompt))
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
243 (string= (substring out 0 (length tmm-c-prompt)) tmm-c-prompt)
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
244 (setq out (substring out (length tmm-c-prompt))
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
245 choice (cdr (assoc out tmm-km-list))))
21688
855aedeb0742 (tmm-get-keymap): Handle new format menu item w/o cache.
Richard M. Stallman <rms@gnu.org>
parents: 21495
diff changeset
246 (and (null choice) out
13916
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
247 (setq out (try-completion out tmm-km-list)
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
248 choice (cdr (assoc out tmm-km-list)))))
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
249 ;; CHOICE is now (STRING . MEANING). Separate the two parts.
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
250 (setq chosen-string (car choice))
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
251 (setq choice (cdr choice))
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
252 (cond (in-popup
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
253 ;; We just did the inner level of a -popup menu.
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
254 choice)
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
255 ;; We just did the outer level. Do the inner level now.
42991
2cc71fdee37e (tmm-get-keymap): Honour :visible in `menu-item'.
Pavel Janík <Pavel@Janik.cz>
parents: 41483
diff changeset
256 (not-menu (tmm-prompt choice t))
13916
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
257 ;; We just handled a menu keymap and found another keymap.
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
258 ((keymapp choice)
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
259 (if (symbolp choice)
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
260 (setq choice (indirect-function choice)))
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
261 (condition-case nil
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
262 (require 'mouse)
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
263 (error nil))
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
264 (tmm-prompt choice))
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
265 ;; We just handled a menu keymap and found a command.
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
266 (choice
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
267 (if chosen-string
14282
63fbb2aeb1f2 (tmm-prompt): Set last-command-event before calling the
Karl Heuer <kwzh@gnu.org>
parents: 14169
diff changeset
268 (progn
63fbb2aeb1f2 (tmm-prompt): Set last-command-event before calling the
Karl Heuer <kwzh@gnu.org>
parents: 14169
diff changeset
269 (setq last-command-event chosen-string)
63fbb2aeb1f2 (tmm-prompt): Set last-command-event before calling the
Karl Heuer <kwzh@gnu.org>
parents: 14169
diff changeset
270 (call-interactively choice))
13916
00065bf711b8 (tmm-prompt): Major cleanups. Handle pop-menu case nicely.
Richard M. Stallman <rms@gnu.org>
parents: 13915
diff changeset
271 choice)))))
10955
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
272
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
273 (defun tmm-add-shortcuts (list)
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
274 "Adds shortcuts to cars of elements of the list.
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
275 Takes a list of lists with a string as car, returns list with
13334
c55f17d3931f (tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents: 12960
diff changeset
276 shortcuts added to these cars.
c55f17d3931f (tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents: 12960
diff changeset
277 Stores a list of all the shortcuts in the free variable `tmm-short-cuts'."
16040
74fc923ff6d5 (tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents: 15564
diff changeset
278 (let ((tmm-next-shortcut-digit ?0))
74fc923ff6d5 (tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents: 15564
diff changeset
279 (mapcar 'tmm-add-one-shortcut (reverse list))))
10955
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
280
16040
74fc923ff6d5 (tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents: 15564
diff changeset
281 (defsubst tmm-add-one-shortcut (elt)
74fc923ff6d5 (tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents: 15564
diff changeset
282 ;; uses the free vars tmm-next-shortcut-digit and tmm-short-cuts
62972
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
283 (cond
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
284 ((eq (cddr elt) 'ignore)
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
285 (cons (concat " " (make-string (length tmm-mid-prompt) ?\-)
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
286 (car elt))
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
287 (cdr elt)))
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
288 (t
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
289 (let* ((str (car elt))
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
290 (paren (string-match "(" str))
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
291 (pos 0) (word 0) char)
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
292 (catch 'done ; ??? is this slow?
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
293 (while (and (or (not tmm-shortcut-words) ; no limit on words
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
294 (< word tmm-shortcut-words)) ; try n words
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
295 (setq pos (string-match "\\w+" str pos)) ; get next word
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
296 (not (and paren (> pos paren)))) ; don't go past "(binding.."
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
297 (if (or (= pos 0)
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
298 (/= (aref str (1- pos)) ?.)) ; avoid file extensions
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
299 (let ((shortcut-style
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
300 (if (listp tmm-shortcut-style) ; convert to list
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
301 tmm-shortcut-style
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
302 (list tmm-shortcut-style))))
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
303 (while shortcut-style ; try upcase and downcase variants
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
304 (setq char (funcall (car shortcut-style) (aref str pos)))
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
305 (if (not (memq char tmm-short-cuts)) (throw 'done char))
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
306 (setq shortcut-style (cdr shortcut-style)))))
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
307 (setq word (1+ word))
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
308 (setq pos (match-end 0)))
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
309 (while (<= tmm-next-shortcut-digit ?9) ; no letter shortcut, pick a digit
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
310 (setq char tmm-next-shortcut-digit)
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
311 (setq tmm-next-shortcut-digit (1+ tmm-next-shortcut-digit))
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
312 (if (not (memq char tmm-short-cuts)) (throw 'done char)))
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
313 (setq char nil))
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
314 (if char (setq tmm-short-cuts (cons char tmm-short-cuts)))
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
315 (cons (concat (if char (concat (char-to-string char) tmm-mid-prompt)
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
316 ;; keep them lined up in columns
74246
27de5ea279da (tmm-add-one-shortcut): "?\ " -> "?\s".
Juanma Barranquero <lekktu@gmail.com>
parents: 68651
diff changeset
317 (make-string (1+ (length tmm-mid-prompt)) ?\s))
62972
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
318 str)
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
319 (cdr elt))))))
16040
74fc923ff6d5 (tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents: 15564
diff changeset
320
74fc923ff6d5 (tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents: 15564
diff changeset
321 ;; This returns the old map.
14902
6dc4dee167eb (tmm-define-keys): New arg MINIBUFFER.
Richard M. Stallman <rms@gnu.org>
parents: 14733
diff changeset
322 (defun tmm-define-keys (minibuffer)
16040
74fc923ff6d5 (tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents: 15564
diff changeset
323 (let ((map (make-sparse-keymap)))
74fc923ff6d5 (tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents: 15564
diff changeset
324 (suppress-keymap map t)
31675
a8e0d20f0043 Replace mapcar with mapc in several places.
Dave Love <fx@gnu.org>
parents: 29290
diff changeset
325 (mapc
a8e0d20f0043 Replace mapcar with mapc in several places.
Dave Love <fx@gnu.org>
parents: 29290
diff changeset
326 (lambda (c)
a8e0d20f0043 Replace mapcar with mapc in several places.
Dave Love <fx@gnu.org>
parents: 29290
diff changeset
327 (if (listp tmm-shortcut-style)
a8e0d20f0043 Replace mapcar with mapc in several places.
Dave Love <fx@gnu.org>
parents: 29290
diff changeset
328 (define-key map (char-to-string c) 'tmm-shortcut)
a8e0d20f0043 Replace mapcar with mapc in several places.
Dave Love <fx@gnu.org>
parents: 29290
diff changeset
329 ;; only one kind of letters are shortcuts, so map both upcase and
a8e0d20f0043 Replace mapcar with mapc in several places.
Dave Love <fx@gnu.org>
parents: 29290
diff changeset
330 ;; downcase input to the same
a8e0d20f0043 Replace mapcar with mapc in several places.
Dave Love <fx@gnu.org>
parents: 29290
diff changeset
331 (define-key map (char-to-string (downcase c)) 'tmm-shortcut)
a8e0d20f0043 Replace mapcar with mapc in several places.
Dave Love <fx@gnu.org>
parents: 29290
diff changeset
332 (define-key map (char-to-string (upcase c)) 'tmm-shortcut)))
16040
74fc923ff6d5 (tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents: 15564
diff changeset
333 tmm-short-cuts)
74fc923ff6d5 (tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents: 15564
diff changeset
334 (if minibuffer
74fc923ff6d5 (tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents: 15564
diff changeset
335 (progn
74fc923ff6d5 (tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents: 15564
diff changeset
336 (define-key map [pageup] 'tmm-goto-completions)
74fc923ff6d5 (tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents: 15564
diff changeset
337 (define-key map [prior] 'tmm-goto-completions)
74fc923ff6d5 (tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents: 15564
diff changeset
338 (define-key map "\ev" 'tmm-goto-completions)
74fc923ff6d5 (tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents: 15564
diff changeset
339 (define-key map "\C-n" 'next-history-element)
74fc923ff6d5 (tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents: 15564
diff changeset
340 (define-key map "\C-p" 'previous-history-element)))
74fc923ff6d5 (tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents: 15564
diff changeset
341 (prog1 (current-local-map)
74fc923ff6d5 (tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents: 15564
diff changeset
342 (use-local-map (append map (current-local-map))))))
74fc923ff6d5 (tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents: 15564
diff changeset
343
74fc923ff6d5 (tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents: 15564
diff changeset
344 (defun tmm-completion-delete-prompt ()
74fc923ff6d5 (tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents: 15564
diff changeset
345 (set-buffer standard-output)
94088
8518c76e4083 (tmm-completion-delete-prompt): Don't hardcode point-min==1.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
346 (goto-char (point-min))
8518c76e4083 (tmm-completion-delete-prompt): Don't hardcode point-min==1.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
347 (delete-region (point) (search-forward "Possible completions are:\n")))
13480
edc4a329403e (tmm-define-keys): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents: 13337
diff changeset
348
62972
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
349 (defun tmm-remove-inactive-mouse-face ()
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
350 "Remove the mouse-face property from inactive menu items."
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
351 (let ((inhibit-read-only t)
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
352 (inactive-string
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
353 (concat " " (make-string (length tmm-mid-prompt) ?\-)))
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
354 next)
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
355 (save-excursion
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
356 (goto-char (point-min))
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
357 (while (not (eobp))
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
358 (setq next (next-single-char-property-change (point) 'mouse-face))
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
359 (when (looking-at inactive-string)
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
360 (remove-text-properties (point) next '(mouse-face))
63082
24720eb84061 (tmm-inactive, tmm-remove-inactive-mouse-face):
Juri Linkov <juri@jurta.org>
parents: 63054
diff changeset
361 (add-text-properties (point) next '(face tmm-inactive)))
62972
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
362 (goto-char next)))
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
363 (set-buffer-modified-p nil)))
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
364
10955
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
365 (defun tmm-add-prompt ()
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
366 (remove-hook 'minibuffer-setup-hook 'tmm-add-prompt)
12763
b8e986069a58 Don't alter bindings in minibuffer-local-must-match-map
Richard M. Stallman <rms@gnu.org>
parents: 10956
diff changeset
367 (add-hook 'minibuffer-exit-hook 'tmm-delete-map nil t)
62972
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
368 (unless tmm-c-prompt
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
369 (error "No active menu entries"))
112238
4f72b1e43644 Merge from emacs-23 branch.
Glenn Morris <rgm@gnu.org>
parents: 112228
diff changeset
370 (setq tmm-old-mb-map (tmm-define-keys t))
4f72b1e43644 Merge from emacs-23 branch.
Glenn Morris <rgm@gnu.org>
parents: 112228
diff changeset
371 ;; Get window and hide it for electric mode to get correct size
4f72b1e43644 Merge from emacs-23 branch.
Glenn Morris <rgm@gnu.org>
parents: 112228
diff changeset
372 (save-window-excursion
4f72b1e43644 Merge from emacs-23 branch.
Glenn Morris <rgm@gnu.org>
parents: 112228
diff changeset
373 (let ((completions
4f72b1e43644 Merge from emacs-23 branch.
Glenn Morris <rgm@gnu.org>
parents: 112228
diff changeset
374 (mapcar 'car minibuffer-completion-table)))
4f72b1e43644 Merge from emacs-23 branch.
Glenn Morris <rgm@gnu.org>
parents: 112228
diff changeset
375 (or tmm-completion-prompt
4f72b1e43644 Merge from emacs-23 branch.
Glenn Morris <rgm@gnu.org>
parents: 112228
diff changeset
376 (add-hook 'completion-setup-hook
4f72b1e43644 Merge from emacs-23 branch.
Glenn Morris <rgm@gnu.org>
parents: 112228
diff changeset
377 'tmm-completion-delete-prompt 'append))
4f72b1e43644 Merge from emacs-23 branch.
Glenn Morris <rgm@gnu.org>
parents: 112228
diff changeset
378 (unwind-protect
4f72b1e43644 Merge from emacs-23 branch.
Glenn Morris <rgm@gnu.org>
parents: 112228
diff changeset
379 (with-output-to-temp-buffer "*Completions*"
4f72b1e43644 Merge from emacs-23 branch.
Glenn Morris <rgm@gnu.org>
parents: 112228
diff changeset
380 (display-completion-list completions))
4f72b1e43644 Merge from emacs-23 branch.
Glenn Morris <rgm@gnu.org>
parents: 112228
diff changeset
381 (remove-hook 'completion-setup-hook 'tmm-completion-delete-prompt)))
4f72b1e43644 Merge from emacs-23 branch.
Glenn Morris <rgm@gnu.org>
parents: 112228
diff changeset
382 (set-buffer "*Completions*")
4f72b1e43644 Merge from emacs-23 branch.
Glenn Morris <rgm@gnu.org>
parents: 112228
diff changeset
383 (tmm-remove-inactive-mouse-face)
4f72b1e43644 Merge from emacs-23 branch.
Glenn Morris <rgm@gnu.org>
parents: 112228
diff changeset
384 (when tmm-completion-prompt
4f72b1e43644 Merge from emacs-23 branch.
Glenn Morris <rgm@gnu.org>
parents: 112228
diff changeset
385 (let ((buffer-read-only nil))
4f72b1e43644 Merge from emacs-23 branch.
Glenn Morris <rgm@gnu.org>
parents: 112228
diff changeset
386 (goto-char (point-min))
4f72b1e43644 Merge from emacs-23 branch.
Glenn Morris <rgm@gnu.org>
parents: 112228
diff changeset
387 (insert tmm-completion-prompt))))
4f72b1e43644 Merge from emacs-23 branch.
Glenn Morris <rgm@gnu.org>
parents: 112228
diff changeset
388 (save-selected-window
4f72b1e43644 Merge from emacs-23 branch.
Glenn Morris <rgm@gnu.org>
parents: 112228
diff changeset
389 (other-window 1) ; Electric-pop-up-window does
10955
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
390 ; not work in minibuffer
112238
4f72b1e43644 Merge from emacs-23 branch.
Glenn Morris <rgm@gnu.org>
parents: 112228
diff changeset
391 (Electric-pop-up-window "*Completions*")
4f72b1e43644 Merge from emacs-23 branch.
Glenn Morris <rgm@gnu.org>
parents: 112228
diff changeset
392 (with-current-buffer "*Completions*"
4f72b1e43644 Merge from emacs-23 branch.
Glenn Morris <rgm@gnu.org>
parents: 112228
diff changeset
393 (setq tmm-old-comp-map (tmm-define-keys nil))))
4f72b1e43644 Merge from emacs-23 branch.
Glenn Morris <rgm@gnu.org>
parents: 112228
diff changeset
394 (insert tmm-c-prompt))
10955
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
395
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
396 (defun tmm-delete-map ()
12763
b8e986069a58 Don't alter bindings in minibuffer-local-must-match-map
Richard M. Stallman <rms@gnu.org>
parents: 10956
diff changeset
397 (remove-hook 'minibuffer-exit-hook 'tmm-delete-map t)
13334
c55f17d3931f (tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents: 12960
diff changeset
398 (if tmm-old-mb-map
c55f17d3931f (tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents: 12960
diff changeset
399 (use-local-map tmm-old-mb-map)))
10955
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
400
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
401 (defun tmm-shortcut ()
13334
c55f17d3931f (tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents: 12960
diff changeset
402 "Choose the shortcut that the user typed."
10955
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
403 (interactive)
101010
4efc7ca085ce Replace last-command-char with last-command-event.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
404 (let ((c last-command-event) s)
16040
74fc923ff6d5 (tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents: 15564
diff changeset
405 (if (symbolp tmm-shortcut-style)
74fc923ff6d5 (tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents: 15564
diff changeset
406 (setq c (funcall tmm-shortcut-style c)))
74fc923ff6d5 (tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents: 15564
diff changeset
407 (if (memq c tmm-short-cuts)
13334
c55f17d3931f (tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents: 12960
diff changeset
408 (if (equal (buffer-name) "*Completions*")
c55f17d3931f (tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents: 12960
diff changeset
409 (progn
62572
f7490b212956 (tmm-shortcut): Avoid using beginning-of-buffer.
Richard M. Stallman <rms@gnu.org>
parents: 62302
diff changeset
410 (goto-char (point-min))
13334
c55f17d3931f (tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents: 12960
diff changeset
411 (re-search-forward
16040
74fc923ff6d5 (tmm-add-one-shortcut): New subroutine.
Richard M. Stallman <rms@gnu.org>
parents: 15564
diff changeset
412 (concat "\\(^\\|[ \t]\\)" (char-to-string c) tmm-mid-prompt))
13334
c55f17d3931f (tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents: 12960
diff changeset
413 (choose-completion))
27289
f6c878d8527c (tmm-shortcut): Delete region after prompt instead
Gerd Moellmann <gerd@gnu.org>
parents: 22482
diff changeset
414 ;; In minibuffer
f6c878d8527c (tmm-shortcut): Delete region after prompt instead
Gerd Moellmann <gerd@gnu.org>
parents: 22482
diff changeset
415 (delete-region (minibuffer-prompt-end) (point-max))
31675
a8e0d20f0043 Replace mapcar with mapc in several places.
Dave Love <fx@gnu.org>
parents: 29290
diff changeset
416 (mapc (lambda (elt)
a8e0d20f0043 Replace mapcar with mapc in several places.
Dave Love <fx@gnu.org>
parents: 29290
diff changeset
417 (if (string=
42991
2cc71fdee37e (tmm-get-keymap): Honour :visible in `menu-item'.
Pavel Janík <Pavel@Janik.cz>
parents: 41483
diff changeset
418 (substring (car elt) 0
31675
a8e0d20f0043 Replace mapcar with mapc in several places.
Dave Love <fx@gnu.org>
parents: 29290
diff changeset
419 (min (1+ (length tmm-mid-prompt))
a8e0d20f0043 Replace mapcar with mapc in several places.
Dave Love <fx@gnu.org>
parents: 29290
diff changeset
420 (length (car elt))))
a8e0d20f0043 Replace mapcar with mapc in several places.
Dave Love <fx@gnu.org>
parents: 29290
diff changeset
421 (concat (char-to-string c) tmm-mid-prompt))
a8e0d20f0043 Replace mapcar with mapc in several places.
Dave Love <fx@gnu.org>
parents: 29290
diff changeset
422 (setq s (car elt))))
13334
c55f17d3931f (tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents: 12960
diff changeset
423 tmm-km-list)
c55f17d3931f (tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents: 12960
diff changeset
424 (insert s)
c55f17d3931f (tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents: 12960
diff changeset
425 (exit-minibuffer)))))
10955
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
426
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
427 (defun tmm-goto-completions ()
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
428 (interactive)
27350
5834ff22d8ce (tmm-goto-completions): Adapt to prompt being part
Gerd Moellmann <gerd@gnu.org>
parents: 27289
diff changeset
429 (let ((prompt-end (minibuffer-prompt-end)))
5834ff22d8ce (tmm-goto-completions): Adapt to prompt being part
Gerd Moellmann <gerd@gnu.org>
parents: 27289
diff changeset
430 (setq tmm-c-prompt (buffer-substring prompt-end (point-max)))
5834ff22d8ce (tmm-goto-completions): Adapt to prompt being part
Gerd Moellmann <gerd@gnu.org>
parents: 27289
diff changeset
431 (delete-region prompt-end (point-max)))
13334
c55f17d3931f (tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents: 12960
diff changeset
432 (switch-to-buffer-other-window "*Completions*")
10955
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
433 (search-forward tmm-c-prompt)
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
434 (search-backward tmm-c-prompt))
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
435
42991
2cc71fdee37e (tmm-get-keymap): Honour :visible in `menu-item'.
Pavel Janík <Pavel@Janik.cz>
parents: 41483
diff changeset
436 (defun tmm-get-keymap (elt &optional in-x-menu)
10955
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
437 "Prepends (DOCSTRING EVENT BINDING) to free variable `tmm-km-list'.
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
438 The values are deduced from the argument ELT, that should be an
13334
c55f17d3931f (tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents: 12960
diff changeset
439 element of keymap, an `x-popup-menu' argument, or an element of
10955
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
440 `x-popup-menu' argument (when IN-X-MENU is not-nil).
13915
1319e4b9aa6c (tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents: 13581
diff changeset
441 This function adds the element only if it is not already present.
1319e4b9aa6c (tmm-menubar-mouse): New function, handles [menu-bar mouse-1].
Richard M. Stallman <rms@gnu.org>
parents: 13581
diff changeset
442 It uses the free variable `tmm-table-undef' to keep undefined keys."
108497
f35b8e7b8a1f Backport from trunk: compute shortcuts in tmm.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107697
diff changeset
443 (let (km str plist filter visible enable (event (car elt)))
10955
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
444 (setq elt (cdr elt))
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
445 (if (eq elt 'undefined)
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
446 (setq tmm-table-undef (cons (cons event nil) tmm-table-undef))
21495
8a45c0e518fa (tmm-get-keymap): Handle `menu-item' menu items.
Karl Heuer <kwzh@gnu.org>
parents: 21088
diff changeset
447 (unless (assoc event tmm-table-undef)
8a45c0e518fa (tmm-get-keymap): Handle `menu-item' menu items.
Karl Heuer <kwzh@gnu.org>
parents: 21088
diff changeset
448 (cond ((if (listp elt)
8a45c0e518fa (tmm-get-keymap): Handle `menu-item' menu items.
Karl Heuer <kwzh@gnu.org>
parents: 21088
diff changeset
449 (or (keymapp elt) (eq (car elt) 'lambda))
108497
f35b8e7b8a1f Backport from trunk: compute shortcuts in tmm.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107697
diff changeset
450 (and (symbolp elt) (fboundp elt)))
21495
8a45c0e518fa (tmm-get-keymap): Handle `menu-item' menu items.
Karl Heuer <kwzh@gnu.org>
parents: 21088
diff changeset
451 (setq km elt))
37811
b496c10108cb (tmm-get-keymap): Fix handling of :filter.
Gerd Moellmann <gerd@gnu.org>
parents: 34281
diff changeset
452
21495
8a45c0e518fa (tmm-get-keymap): Handle `menu-item' menu items.
Karl Heuer <kwzh@gnu.org>
parents: 21088
diff changeset
453 ((if (listp (cdr-safe elt))
8a45c0e518fa (tmm-get-keymap): Handle `menu-item' menu items.
Karl Heuer <kwzh@gnu.org>
parents: 21088
diff changeset
454 (or (keymapp (cdr-safe elt))
8a45c0e518fa (tmm-get-keymap): Handle `menu-item' menu items.
Karl Heuer <kwzh@gnu.org>
parents: 21088
diff changeset
455 (eq (car (cdr-safe elt)) 'lambda))
108497
f35b8e7b8a1f Backport from trunk: compute shortcuts in tmm.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107697
diff changeset
456 (and (symbolp (cdr-safe elt)) (fboundp (cdr-safe elt))))
21495
8a45c0e518fa (tmm-get-keymap): Handle `menu-item' menu items.
Karl Heuer <kwzh@gnu.org>
parents: 21088
diff changeset
457 (setq km (cdr elt))
8a45c0e518fa (tmm-get-keymap): Handle `menu-item' menu items.
Karl Heuer <kwzh@gnu.org>
parents: 21088
diff changeset
458 (and (stringp (car elt)) (setq str (car elt))))
37811
b496c10108cb (tmm-get-keymap): Fix handling of :filter.
Gerd Moellmann <gerd@gnu.org>
parents: 34281
diff changeset
459
21495
8a45c0e518fa (tmm-get-keymap): Handle `menu-item' menu items.
Karl Heuer <kwzh@gnu.org>
parents: 21088
diff changeset
460 ((if (listp (cdr-safe (cdr-safe elt)))
8a45c0e518fa (tmm-get-keymap): Handle `menu-item' menu items.
Karl Heuer <kwzh@gnu.org>
parents: 21088
diff changeset
461 (or (keymapp (cdr-safe (cdr-safe elt)))
8a45c0e518fa (tmm-get-keymap): Handle `menu-item' menu items.
Karl Heuer <kwzh@gnu.org>
parents: 21088
diff changeset
462 (eq (car (cdr-safe (cdr-safe elt))) 'lambda))
108497
f35b8e7b8a1f Backport from trunk: compute shortcuts in tmm.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107697
diff changeset
463 (and (symbolp (cdr-safe (cdr-safe elt)))
f35b8e7b8a1f Backport from trunk: compute shortcuts in tmm.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107697
diff changeset
464 (fboundp (cdr-safe (cdr-safe elt)))))
99230
00ad633e13ee (tmm-get-keymap): Handle case where keyseq cache is omitted.
Chong Yidong <cyd@stupidchicken.com>
parents: 94678
diff changeset
465 (setq km (cddr elt))
108497
f35b8e7b8a1f Backport from trunk: compute shortcuts in tmm.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107697
diff changeset
466 (and (stringp (car elt)) (setq str (car elt))))
37811
b496c10108cb (tmm-get-keymap): Fix handling of :filter.
Gerd Moellmann <gerd@gnu.org>
parents: 34281
diff changeset
467
21495
8a45c0e518fa (tmm-get-keymap): Handle `menu-item' menu items.
Karl Heuer <kwzh@gnu.org>
parents: 21088
diff changeset
468 ((eq (car-safe elt) 'menu-item)
37811
b496c10108cb (tmm-get-keymap): Fix handling of :filter.
Gerd Moellmann <gerd@gnu.org>
parents: 34281
diff changeset
469 ;; (menu-item TITLE COMMAND KEY ...)
22482
eb09852bfc05 (tmm-get-keymap): Handle :filter.
Richard M. Stallman <rms@gnu.org>
parents: 21952
diff changeset
470 (setq plist (cdr-safe (cdr-safe (cdr-safe elt))))
37811
b496c10108cb (tmm-get-keymap): Fix handling of :filter.
Gerd Moellmann <gerd@gnu.org>
parents: 34281
diff changeset
471 (when (consp (car-safe plist))
b496c10108cb (tmm-get-keymap): Fix handling of :filter.
Gerd Moellmann <gerd@gnu.org>
parents: 34281
diff changeset
472 (setq plist (cdr-safe plist)))
21495
8a45c0e518fa (tmm-get-keymap): Handle `menu-item' menu items.
Karl Heuer <kwzh@gnu.org>
parents: 21088
diff changeset
473 (setq km (nth 2 elt))
34137
c95b5f588978 (tmm-get-keymap): Eval the menu name in `menu-item'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31675
diff changeset
474 (setq str (eval (nth 1 elt)))
22482
eb09852bfc05 (tmm-get-keymap): Handle :filter.
Richard M. Stallman <rms@gnu.org>
parents: 21952
diff changeset
475 (setq filter (plist-get plist :filter))
eb09852bfc05 (tmm-get-keymap): Handle :filter.
Richard M. Stallman <rms@gnu.org>
parents: 21952
diff changeset
476 (if filter
eb09852bfc05 (tmm-get-keymap): Handle :filter.
Richard M. Stallman <rms@gnu.org>
parents: 21952
diff changeset
477 (setq km (funcall filter km)))
42991
2cc71fdee37e (tmm-get-keymap): Honour :visible in `menu-item'.
Pavel Janík <Pavel@Janik.cz>
parents: 41483
diff changeset
478 (setq visible (plist-get plist :visible))
2cc71fdee37e (tmm-get-keymap): Honour :visible in `menu-item'.
Pavel Janík <Pavel@Janik.cz>
parents: 41483
diff changeset
479 (if visible
2cc71fdee37e (tmm-get-keymap): Honour :visible in `menu-item'.
Pavel Janík <Pavel@Janik.cz>
parents: 41483
diff changeset
480 (setq km (and (eval visible) km)))
62302
587868b19cb8 (tmm-get-keymap): Include only active menus and menu items.
Nick Roberts <nickrob@snap.net.nz>
parents: 52401
diff changeset
481 (setq enable (plist-get plist :enable))
587868b19cb8 (tmm-get-keymap): Include only active menus and menu items.
Nick Roberts <nickrob@snap.net.nz>
parents: 52401
diff changeset
482 (if enable
108497
f35b8e7b8a1f Backport from trunk: compute shortcuts in tmm.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107697
diff changeset
483 (setq km (if (eval enable) km 'ignore))))
37811
b496c10108cb (tmm-get-keymap): Fix handling of :filter.
Gerd Moellmann <gerd@gnu.org>
parents: 34281
diff changeset
484
21495
8a45c0e518fa (tmm-get-keymap): Handle `menu-item' menu items.
Karl Heuer <kwzh@gnu.org>
parents: 21088
diff changeset
485 ((if (listp (cdr-safe (cdr-safe (cdr-safe elt))))
8a45c0e518fa (tmm-get-keymap): Handle `menu-item' menu items.
Karl Heuer <kwzh@gnu.org>
parents: 21088
diff changeset
486 (or (keymapp (cdr-safe (cdr-safe (cdr-safe elt))))
8a45c0e518fa (tmm-get-keymap): Handle `menu-item' menu items.
Karl Heuer <kwzh@gnu.org>
parents: 21088
diff changeset
487 (eq (car (cdr-safe (cdr-safe (cdr-safe elt)))) 'lambda))
108497
f35b8e7b8a1f Backport from trunk: compute shortcuts in tmm.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107697
diff changeset
488 (and (symbolp (cdr-safe (cdr-safe (cdr-safe elt))))
f35b8e7b8a1f Backport from trunk: compute shortcuts in tmm.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107697
diff changeset
489 (fboundp (cdr-safe (cdr-safe (cdr-safe elt))))))
21495
8a45c0e518fa (tmm-get-keymap): Handle `menu-item' menu items.
Karl Heuer <kwzh@gnu.org>
parents: 21088
diff changeset
490 ; New style of easy-menu
99230
00ad633e13ee (tmm-get-keymap): Handle case where keyseq cache is omitted.
Chong Yidong <cyd@stupidchicken.com>
parents: 94678
diff changeset
491 (setq km (cdr (cddr elt)))
108497
f35b8e7b8a1f Backport from trunk: compute shortcuts in tmm.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107697
diff changeset
492 (and (stringp (car elt)) (setq str (car elt))))
37811
b496c10108cb (tmm-get-keymap): Fix handling of :filter.
Gerd Moellmann <gerd@gnu.org>
parents: 34281
diff changeset
493
21495
8a45c0e518fa (tmm-get-keymap): Handle `menu-item' menu items.
Karl Heuer <kwzh@gnu.org>
parents: 21088
diff changeset
494 ((stringp event) ; x-popup or x-popup element
8a45c0e518fa (tmm-get-keymap): Handle `menu-item' menu items.
Karl Heuer <kwzh@gnu.org>
parents: 21088
diff changeset
495 (if (or in-x-menu (stringp (car-safe elt)))
8a45c0e518fa (tmm-get-keymap): Handle `menu-item' menu items.
Karl Heuer <kwzh@gnu.org>
parents: 21088
diff changeset
496 (setq str event event nil km elt)
108497
f35b8e7b8a1f Backport from trunk: compute shortcuts in tmm.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107697
diff changeset
497 (setq str event event nil km (cons 'keymap elt)))))
112238
4f72b1e43644 Merge from emacs-23 branch.
Glenn Morris <rgm@gnu.org>
parents: 112228
diff changeset
498 (unless (or (eq km 'ignore) (null str))
108497
f35b8e7b8a1f Backport from trunk: compute shortcuts in tmm.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107697
diff changeset
499 (let ((binding (where-is-internal km nil t)))
f35b8e7b8a1f Backport from trunk: compute shortcuts in tmm.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107697
diff changeset
500 (when binding
f35b8e7b8a1f Backport from trunk: compute shortcuts in tmm.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107697
diff changeset
501 (setq binding (key-description binding))
f35b8e7b8a1f Backport from trunk: compute shortcuts in tmm.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107697
diff changeset
502 ;; Try to align the keybindings.
f35b8e7b8a1f Backport from trunk: compute shortcuts in tmm.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107697
diff changeset
503 (let ((colwidth (min 30 (- (/ (window-width) 2) 10))))
f35b8e7b8a1f Backport from trunk: compute shortcuts in tmm.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107697
diff changeset
504 (setq str
f35b8e7b8a1f Backport from trunk: compute shortcuts in tmm.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107697
diff changeset
505 (concat str
f35b8e7b8a1f Backport from trunk: compute shortcuts in tmm.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107697
diff changeset
506 (make-string (max 2 (- colwidth
f35b8e7b8a1f Backport from trunk: compute shortcuts in tmm.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107697
diff changeset
507 (string-width str)
f35b8e7b8a1f Backport from trunk: compute shortcuts in tmm.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107697
diff changeset
508 (string-width binding)))
f35b8e7b8a1f Backport from trunk: compute shortcuts in tmm.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107697
diff changeset
509 ?\s)
f35b8e7b8a1f Backport from trunk: compute shortcuts in tmm.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107697
diff changeset
510 binding)))))))
10955
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
511 (and km (stringp km) (setq str km))
19505
fe381b9e1953 (tmm-get-keymap): Ignore any command now disabled for menus.
Richard M. Stallman <rms@gnu.org>
parents: 18810
diff changeset
512 ;; Verify that the command is enabled;
fe381b9e1953 (tmm-get-keymap): Ignore any command now disabled for menus.
Richard M. Stallman <rms@gnu.org>
parents: 18810
diff changeset
513 ;; if not, don't mention it.
fe381b9e1953 (tmm-get-keymap): Ignore any command now disabled for menus.
Richard M. Stallman <rms@gnu.org>
parents: 18810
diff changeset
514 (when (and km (symbolp km) (get km 'menu-enable))
62972
6331f03975bb (tmm-inactive-face): New face.
Nick Roberts <nickrob@snap.net.nz>
parents: 62572
diff changeset
515 (setq km (if (eval (get km 'menu-enable)) km 'ignore)))
10955
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
516 (and km str
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
517 (or (assoc str tmm-km-list)
34137
c95b5f588978 (tmm-get-keymap): Eval the menu name in `menu-item'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31675
diff changeset
518 (push (cons str (cons event km)) tmm-km-list))))))
10955
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
519
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
520 (defun tmm-get-keybind (keyseq)
13334
c55f17d3931f (tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents: 12960
diff changeset
521 "Return the current binding of KEYSEQ, merging prefix definitions.
14011
6427a3484344 (tmm-get-keybind): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 13916
diff changeset
522 If KEYSEQ is a prefix key that has local and global bindings,
13334
c55f17d3931f (tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents: 12960
diff changeset
523 we merge them into a single keymap which shows the proper order of the menu.
c55f17d3931f (tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents: 12960
diff changeset
524 However, for the menu bar itself, the value does not take account
c55f17d3931f (tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents: 12960
diff changeset
525 of `menu-bar-final-items'."
76905
624ef730616c (tmm-c-prompt): Initialize.
Nick Roberts <nickrob@snap.net.nz>
parents: 76802
diff changeset
526 (let (allbind bind minorbind localbind globalbind)
13334
c55f17d3931f (tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents: 12960
diff changeset
527 (setq bind (key-binding keyseq))
c55f17d3931f (tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents: 12960
diff changeset
528 ;; If KEYSEQ is a prefix key, then BIND is either nil
c55f17d3931f (tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents: 12960
diff changeset
529 ;; or a symbol defined as a keymap (which satisfies keymapp).
c55f17d3931f (tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents: 12960
diff changeset
530 (if (keymapp bind)
c55f17d3931f (tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents: 12960
diff changeset
531 (setq bind nil))
c55f17d3931f (tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents: 12960
diff changeset
532 ;; If we have a non-keymap definition, return that.
c55f17d3931f (tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents: 12960
diff changeset
533 (or bind
c55f17d3931f (tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents: 12960
diff changeset
534 (progn
c55f17d3931f (tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents: 12960
diff changeset
535 ;; Otherwise, it is a prefix, so make a list of the subcommands.
c55f17d3931f (tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents: 12960
diff changeset
536 ;; Make a list of all the bindings in all the keymaps.
76905
624ef730616c (tmm-c-prompt): Initialize.
Nick Roberts <nickrob@snap.net.nz>
parents: 76802
diff changeset
537 (setq minorbind (mapcar 'cdr (minor-mode-key-binding keyseq)))
624ef730616c (tmm-c-prompt): Initialize.
Nick Roberts <nickrob@snap.net.nz>
parents: 76802
diff changeset
538 (setq localbind (local-key-binding keyseq))
77198
4588da3832c6 (tmm-get-keybind): Use copy-sequence to ensure that the
Nick Roberts <nickrob@snap.net.nz>
parents: 77162
diff changeset
539 (setq globalbind (copy-sequence (cdr (global-key-binding keyseq))))
76905
624ef730616c (tmm-c-prompt): Initialize.
Nick Roberts <nickrob@snap.net.nz>
parents: 76802
diff changeset
540
624ef730616c (tmm-c-prompt): Initialize.
Nick Roberts <nickrob@snap.net.nz>
parents: 76802
diff changeset
541 ;; If items have been redefined/undefined locally, remove them from
624ef730616c (tmm-c-prompt): Initialize.
Nick Roberts <nickrob@snap.net.nz>
parents: 76802
diff changeset
542 ;; the global list.
624ef730616c (tmm-c-prompt): Initialize.
Nick Roberts <nickrob@snap.net.nz>
parents: 76802
diff changeset
543 (dolist (minor minorbind)
624ef730616c (tmm-c-prompt): Initialize.
Nick Roberts <nickrob@snap.net.nz>
parents: 76802
diff changeset
544 (dolist (item (cdr minor))
77162
3c1a4db3e853 (tmm-get-keybind): Use car-safe to avoid errors with
Nick Roberts <nickrob@snap.net.nz>
parents: 76911
diff changeset
545 (setq globalbind (assq-delete-all (car-safe item) globalbind))))
76905
624ef730616c (tmm-c-prompt): Initialize.
Nick Roberts <nickrob@snap.net.nz>
parents: 76802
diff changeset
546 (dolist (item (cdr localbind))
77162
3c1a4db3e853 (tmm-get-keybind): Use car-safe to avoid errors with
Nick Roberts <nickrob@snap.net.nz>
parents: 76911
diff changeset
547 (setq globalbind (assq-delete-all (car-safe item) globalbind)))
76905
624ef730616c (tmm-c-prompt): Initialize.
Nick Roberts <nickrob@snap.net.nz>
parents: 76802
diff changeset
548
624ef730616c (tmm-c-prompt): Initialize.
Nick Roberts <nickrob@snap.net.nz>
parents: 76802
diff changeset
549 (setq globalbind (cons 'keymap globalbind))
624ef730616c (tmm-c-prompt): Initialize.
Nick Roberts <nickrob@snap.net.nz>
parents: 76802
diff changeset
550 (setq allbind (cons globalbind (cons localbind minorbind)))
624ef730616c (tmm-c-prompt): Initialize.
Nick Roberts <nickrob@snap.net.nz>
parents: 76802
diff changeset
551
13334
c55f17d3931f (tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents: 12960
diff changeset
552 ;; Merge all the elements of ALLBIND into one keymap.
31675
a8e0d20f0043 Replace mapcar with mapc in several places.
Dave Love <fx@gnu.org>
parents: 29290
diff changeset
553 (mapc (lambda (in)
a8e0d20f0043 Replace mapcar with mapc in several places.
Dave Love <fx@gnu.org>
parents: 29290
diff changeset
554 (if (and (symbolp in) (keymapp in))
a8e0d20f0043 Replace mapcar with mapc in several places.
Dave Love <fx@gnu.org>
parents: 29290
diff changeset
555 (setq in (symbol-function in)))
a8e0d20f0043 Replace mapcar with mapc in several places.
Dave Love <fx@gnu.org>
parents: 29290
diff changeset
556 (and in (keymapp in)
a8e0d20f0043 Replace mapcar with mapc in several places.
Dave Love <fx@gnu.org>
parents: 29290
diff changeset
557 (if (keymapp bind)
a8e0d20f0043 Replace mapcar with mapc in several places.
Dave Love <fx@gnu.org>
parents: 29290
diff changeset
558 (setq bind (nconc bind (copy-sequence (cdr in))))
a8e0d20f0043 Replace mapcar with mapc in several places.
Dave Love <fx@gnu.org>
parents: 29290
diff changeset
559 (setq bind (copy-sequence in)))))
13334
c55f17d3931f (tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents: 12960
diff changeset
560 allbind)
c55f17d3931f (tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents: 12960
diff changeset
561 ;; Return that keymap.
c55f17d3931f (tmm-old-mb-map): Initialize to nil.
Richard M. Stallman <rms@gnu.org>
parents: 12960
diff changeset
562 bind))))
10955
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
563
84430
490362706869 Remove spurious * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 83648
diff changeset
564 ;; Huh? What's that about? --Stef
10955
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
565 (add-hook 'calendar-load-hook (lambda () (require 'cal-menu)))
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
566
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
567 (provide 'tmm)
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
568
1bbdc8c907ea Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
569 ;;; tmm.el ends here