annotate lisp/edmacro.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
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1 ;;; edmacro.el --- keyboard macro editor
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
2
74439
ddcbd2c1b70d Update copyright years.
Glenn Morris <rgm@gnu.org>
parents: 72246
diff changeset
3 ;; Copyright (C) 1993, 1994, 2001, 2002, 2003, 2004,
112218
376148b31b5e Add 2011 to FSF/AIST copyright years.
Glenn Morris <rgm@gnu.org>
parents: 106815
diff changeset
4 ;; 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
845
213978acbc1e entered into RCS
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 807
diff changeset
5
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
6 ;; Author: Dave Gillespie <daveg@synaptics.com>
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
7 ;; Maintainer: Dave Gillespie <daveg@synaptics.com>
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
8 ;; Version: 2.01
2247
2c7997f249eb Add or correct keywords
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 845
diff changeset
9 ;; Keywords: abbrev
109
d649664df7e0 Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
10
d649664df7e0 Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
11 ;; This file is part of GNU Emacs.
d649664df7e0 Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
12
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
13 ;; GNU Emacs is free software: you can redistribute it and/or modify
109
d649664df7e0 Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
14 ;; 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: 93975
diff changeset
15 ;; 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: 93975
diff changeset
16 ;; (at your option) any later version.
109
d649664df7e0 Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
17
d649664df7e0 Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
18 ;; GNU Emacs is distributed in the hope that it will be useful,
d649664df7e0 Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
d649664df7e0 Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d649664df7e0 Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
21 ;; GNU General Public License for more details.
d649664df7e0 Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
22
d649664df7e0 Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
23 ;; 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: 93975
diff changeset
24 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
109
d649664df7e0 Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
25
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
26 ;;; Commentary:
109
d649664df7e0 Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
27
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
28 ;;; Usage:
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
29 ;;
58836
89cc919b0ccd `edit-kbd-macro' is now bound to `C-x C-k e'.
Luc Teirlinck <teirllm@auburn.edu>
parents: 57292
diff changeset
30 ;; The `C-x C-k e' (`edit-kbd-macro') command edits a keyboard macro
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
31 ;; in a special buffer. It prompts you to type a key sequence,
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
32 ;; which should be one of:
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
33 ;;
49588
37645a051842 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47404
diff changeset
34 ;; * RET or `C-x e' (call-last-kbd-macro), to edit the most
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
35 ;; recently defined keyboard macro.
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
36 ;;
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
37 ;; * `M-x' followed by a command name, to edit a named command
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
38 ;; whose definition is a keyboard macro.
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
39 ;;
98621
835147d28933 * help.el (view-lossage): Fix docstring, lossage is now 300 keys.
Romain Francoise <romain@orebokech.com>
parents: 98133
diff changeset
40 ;; * `C-h l' (view-lossage), to edit the 300 most recent keystrokes
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
41 ;; and install them as the "current" macro.
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
42 ;;
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
43 ;; * any key sequence whose definition is a keyboard macro.
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
44 ;;
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
45 ;; This file includes a version of `insert-kbd-macro' that uses the
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
46 ;; more readable format defined by these routines.
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
47 ;;
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
48 ;; Also, the `read-kbd-macro' command parses the region as
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
49 ;; a keyboard macro, and installs it as the "current" macro.
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
50 ;; This and `format-kbd-macro' can also be called directly as
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
51 ;; Lisp functions.
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
52
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
53 ;; Type `C-h m', or see the documentation for `edmacro-mode' below,
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
54 ;; for information about the format of written keyboard macros.
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
55
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
56 ;; `edit-kbd-macro' formats the macro with one command per line,
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
57 ;; including the command names as comments on the right. If the
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
58 ;; formatter gets confused about which keymap was used for the
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
59 ;; characters, the command-name comments will be wrong but that
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
60 ;; won't hurt anything.
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
61
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
62 ;; With a prefix argument, `edit-kbd-macro' will format the
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
63 ;; macro in a more concise way that omits the comments.
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
64
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
65 ;; This package requires GNU Emacs 19 or later, and daveg's CL
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
66 ;; package 2.02 or later. (CL 2.02 comes standard starting with
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
67 ;; Emacs 19.18.) This package does not work with Emacs 18 or
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
68 ;; Lucid Emacs.
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
69
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
70 ;;; Code:
109
d649664df7e0 Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
71
12955
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
72 (eval-when-compile
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
73 (require 'cl))
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
74
57292
00748c19ee41 Require kmacro to use the new kmacro-lambda-form and
Kim F. Storm <storm@cua.dk>
parents: 52401
diff changeset
75 (require 'kmacro)
00748c19ee41 Require kmacro to use the new kmacro-lambda-form and
Kim F. Storm <storm@cua.dk>
parents: 52401
diff changeset
76
109
d649664df7e0 Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
77 ;;; The user-level commands for editing macros.
d649664df7e0 Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
78
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
79 ;;;###autoload
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
80 (defvar edmacro-eight-bits nil
99097
8f4ff9c9a49c * edmacro.el (edmacro-eight-bits, edmacro-mode): Fix docstring typos.
Juanma Barranquero <lekktu@gmail.com>
parents: 98621
diff changeset
81 "*Non-nil if `edit-kbd-macro' should leave 8-bit characters intact.
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
82 Default nil means to write characters above \\177 in octal notation.")
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
83
110909
cc035ccb9275 Declare and define in one step various mode maps.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 106815
diff changeset
84 (defvar edmacro-mode-map
cc035ccb9275 Declare and define in one step various mode maps.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 106815
diff changeset
85 (let ((map (make-sparse-keymap)))
cc035ccb9275 Declare and define in one step various mode maps.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 106815
diff changeset
86 (define-key map "\C-c\C-c" 'edmacro-finish-edit)
cc035ccb9275 Declare and define in one step various mode maps.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 106815
diff changeset
87 (define-key map "\C-c\C-q" 'edmacro-insert-key)
cc035ccb9275 Declare and define in one step various mode maps.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 106815
diff changeset
88 map))
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
89
14464
fea038c6da68 (edmacro-original-buffer, edmacro-finish-hook)
Richard M. Stallman <rms@gnu.org>
parents: 14397
diff changeset
90 (defvar edmacro-store-hook)
fea038c6da68 (edmacro-original-buffer, edmacro-finish-hook)
Richard M. Stallman <rms@gnu.org>
parents: 14397
diff changeset
91 (defvar edmacro-finish-hook)
fea038c6da68 (edmacro-original-buffer, edmacro-finish-hook)
Richard M. Stallman <rms@gnu.org>
parents: 14397
diff changeset
92 (defvar edmacro-original-buffer)
fea038c6da68 (edmacro-original-buffer, edmacro-finish-hook)
Richard M. Stallman <rms@gnu.org>
parents: 14397
diff changeset
93
258
1e0bc00dca7a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 199
diff changeset
94 ;;;###autoload
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
95 (defun edit-kbd-macro (keys &optional prefix finish-hook store-hook)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
96 "Edit a keyboard macro.
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
97 At the prompt, type any key sequence which is bound to a keyboard macro.
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
98 Or, type `C-x e' or RET to edit the last keyboard macro, `C-h l' to edit
98621
835147d28933 * help.el (view-lossage): Fix docstring, lossage is now 300 keys.
Romain Francoise <romain@orebokech.com>
parents: 98133
diff changeset
99 the last 300 keystrokes as a keyboard macro, or `M-x' to edit a macro by
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
100 its command name.
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
101 With a prefix argument, format the macro in a more concise way."
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
102 (interactive "kKeyboard macro to edit (C-x e, M-x, C-h l, or keys): \nP")
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
103 (when keys
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
104 (let ((cmd (if (arrayp keys) (key-binding keys) keys))
57292
00748c19ee41 Require kmacro to use the new kmacro-lambda-form and
Kim F. Storm <storm@cua.dk>
parents: 52401
diff changeset
105 (mac nil) (mac-counter nil) (mac-format nil)
00748c19ee41 Require kmacro to use the new kmacro-lambda-form and
Kim F. Storm <storm@cua.dk>
parents: 52401
diff changeset
106 kmacro)
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
107 (cond (store-hook
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
108 (setq mac keys)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
109 (setq cmd nil))
49588
37645a051842 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47404
diff changeset
110 ((or (memq cmd '(call-last-kbd-macro kmacro-call-macro
47404
51b92fc1f484 (edit-kbd-macro): Recognize new C-x e binding, kmacro-end-and-call-macro.
Kim F. Storm <storm@cua.dk>
parents: 47294
diff changeset
111 kmacro-end-or-call-macro kmacro-end-and-call-macro))
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
112 (member keys '("\r" [return])))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
113 (or last-kbd-macro
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
114 (y-or-n-p "No keyboard macro defined. Create one? ")
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
115 (keyboard-quit))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
116 (setq mac (or last-kbd-macro ""))
57292
00748c19ee41 Require kmacro to use the new kmacro-lambda-form and
Kim F. Storm <storm@cua.dk>
parents: 52401
diff changeset
117 (setq keys nil)
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
118 (setq cmd 'last-kbd-macro))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
119 ((eq cmd 'execute-extended-command)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
120 (setq cmd (read-command "Name of keyboard macro to edit: "))
14397
49d961cdc9d6 (edit-kbd-macro): Reject empty cmd name.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
121 (if (string-equal cmd "")
49d961cdc9d6 (edit-kbd-macro): Reject empty cmd name.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
122 (error "No command name given"))
57292
00748c19ee41 Require kmacro to use the new kmacro-lambda-form and
Kim F. Storm <storm@cua.dk>
parents: 52401
diff changeset
123 (setq keys nil)
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
124 (setq mac (symbol-function cmd)))
23945
688314651e5a (edit-kbd-macro): Recognize electric-view-lossage.
Richard M. Stallman <rms@gnu.org>
parents: 16977
diff changeset
125 ((memq cmd '(view-lossage electric-view-lossage))
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
126 (setq mac (recent-keys))
57292
00748c19ee41 Require kmacro to use the new kmacro-lambda-form and
Kim F. Storm <storm@cua.dk>
parents: 52401
diff changeset
127 (setq keys nil)
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
128 (setq cmd 'last-kbd-macro))
11870
993431cf1f89 (edit-kbd-macro): Better error messages for undefined keys
Karl Heuer <kwzh@gnu.org>
parents: 10692
diff changeset
129 ((null cmd)
993431cf1f89 (edit-kbd-macro): Better error messages for undefined keys
Karl Heuer <kwzh@gnu.org>
parents: 10692
diff changeset
130 (error "Key sequence %s is not defined" (key-description keys)))
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
131 ((symbolp cmd)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
132 (setq mac (symbol-function cmd)))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
133 (t
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
134 (setq mac cmd)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
135 (setq cmd nil)))
57292
00748c19ee41 Require kmacro to use the new kmacro-lambda-form and
Kim F. Storm <storm@cua.dk>
parents: 52401
diff changeset
136 (when (setq kmacro (kmacro-extract-lambda mac))
00748c19ee41 Require kmacro to use the new kmacro-lambda-form and
Kim F. Storm <storm@cua.dk>
parents: 52401
diff changeset
137 (setq mac (car kmacro)
00748c19ee41 Require kmacro to use the new kmacro-lambda-form and
Kim F. Storm <storm@cua.dk>
parents: 52401
diff changeset
138 mac-counter (nth 1 kmacro)
00748c19ee41 Require kmacro to use the new kmacro-lambda-form and
Kim F. Storm <storm@cua.dk>
parents: 52401
diff changeset
139 mac-format (nth 2 kmacro)))
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
140 (unless (arrayp mac)
11870
993431cf1f89 (edit-kbd-macro): Better error messages for undefined keys
Karl Heuer <kwzh@gnu.org>
parents: 10692
diff changeset
141 (error "Key sequence %s is not a keyboard macro"
993431cf1f89 (edit-kbd-macro): Better error messages for undefined keys
Karl Heuer <kwzh@gnu.org>
parents: 10692
diff changeset
142 (key-description keys)))
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
143 (message "Formatting keyboard macro...")
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
144 (let* ((oldbuf (current-buffer))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
145 (mmac (edmacro-fix-menu-commands mac))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
146 (fmt (edmacro-format-keys mmac 1))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
147 (fmtv (edmacro-format-keys mmac (not prefix)))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
148 (buf (get-buffer-create "*Edit Macro*")))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
149 (message "Formatting keyboard macro...done")
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
150 (switch-to-buffer buf)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
151 (kill-all-local-variables)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
152 (use-local-map edmacro-mode-map)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
153 (setq buffer-read-only nil)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
154 (setq major-mode 'edmacro-mode)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
155 (setq mode-name "Edit Macro")
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
156 (set (make-local-variable 'edmacro-original-buffer) oldbuf)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
157 (set (make-local-variable 'edmacro-finish-hook) finish-hook)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
158 (set (make-local-variable 'edmacro-store-hook) store-hook)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
159 (erase-buffer)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
160 (insert ";; Keyboard Macro Editor. Press C-c C-c to finish; "
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
161 "press C-x k RET to cancel.\n")
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
162 (insert ";; Original keys: " fmt "\n")
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
163 (unless store-hook
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
164 (insert "\nCommand: " (if cmd (symbol-name cmd) "none") "\n")
57292
00748c19ee41 Require kmacro to use the new kmacro-lambda-form and
Kim F. Storm <storm@cua.dk>
parents: 52401
diff changeset
165 (let ((gkeys (where-is-internal (or cmd mac) '(keymap))))
00748c19ee41 Require kmacro to use the new kmacro-lambda-form and
Kim F. Storm <storm@cua.dk>
parents: 52401
diff changeset
166 (if (and keys (not (member keys gkeys)))
00748c19ee41 Require kmacro to use the new kmacro-lambda-form and
Kim F. Storm <storm@cua.dk>
parents: 52401
diff changeset
167 (setq gkeys (cons keys gkeys)))
00748c19ee41 Require kmacro to use the new kmacro-lambda-form and
Kim F. Storm <storm@cua.dk>
parents: 52401
diff changeset
168 (if gkeys
00748c19ee41 Require kmacro to use the new kmacro-lambda-form and
Kim F. Storm <storm@cua.dk>
parents: 52401
diff changeset
169 (while gkeys
00748c19ee41 Require kmacro to use the new kmacro-lambda-form and
Kim F. Storm <storm@cua.dk>
parents: 52401
diff changeset
170 (insert "Key: " (edmacro-format-keys (pop gkeys) 1) "\n"))
00748c19ee41 Require kmacro to use the new kmacro-lambda-form and
Kim F. Storm <storm@cua.dk>
parents: 52401
diff changeset
171 (insert "Key: none\n")))
00748c19ee41 Require kmacro to use the new kmacro-lambda-form and
Kim F. Storm <storm@cua.dk>
parents: 52401
diff changeset
172 (when (and mac-counter mac-format)
00748c19ee41 Require kmacro to use the new kmacro-lambda-form and
Kim F. Storm <storm@cua.dk>
parents: 52401
diff changeset
173 (insert (format "Counter: %d\nFormat: \"%s\"\n" mac-counter mac-format))))
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
174 (insert "\nMacro:\n\n")
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
175 (save-excursion
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
176 (insert fmtv "\n"))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
177 (recenter '(4))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
178 (when (eq mac mmac)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
179 (set-buffer-modified-p nil))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
180 (run-hooks 'edmacro-format-hook)))))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
181
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
182 ;;; The next two commands are provided for convenience and backward
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
183 ;;; compatibility.
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
184
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
185 ;;;###autoload
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
186 (defun edit-last-kbd-macro (&optional prefix)
109
d649664df7e0 Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
187 "Edit the most recently defined keyboard macro."
d649664df7e0 Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
188 (interactive "P")
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
189 (edit-kbd-macro 'call-last-kbd-macro prefix))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
190
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
191 ;;;###autoload
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
192 (defun edit-named-kbd-macro (&optional prefix)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
193 "Edit a keyboard macro which has been given a name by `name-last-kbd-macro'."
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
194 (interactive "P")
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
195 (edit-kbd-macro 'execute-extended-command prefix))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
196
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
197 ;;;###autoload
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
198 (defun read-kbd-macro (start &optional end)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
199 "Read the region as a keyboard macro definition.
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
200 The region is interpreted as spelled-out keystrokes, e.g., \"M-x abc RET\".
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
201 See documentation for `edmacro-mode' for details.
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
202 Leading/trailing \"C-x (\" and \"C-x )\" in the text are allowed and ignored.
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
203 The resulting macro is installed as the \"current\" keyboard macro.
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
204
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
205 In Lisp, may also be called with a single STRING argument in which case
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
206 the result is returned rather than being installed as the current macro.
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
207 The result will be a string if possible, otherwise an event vector.
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
208 Second argument NEED-VECTOR means to return an event vector always."
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
209 (interactive "r")
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
210 (if (stringp start)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
211 (edmacro-parse-keys start end)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
212 (setq last-kbd-macro (edmacro-parse-keys (buffer-substring start end)))))
109
d649664df7e0 Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
213
258
1e0bc00dca7a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 199
diff changeset
214 ;;;###autoload
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
215 (defun format-kbd-macro (&optional macro verbose)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
216 "Return the keyboard macro MACRO as a human-readable string.
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
217 This string is suitable for passing to `read-kbd-macro'.
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
218 Second argument VERBOSE means to put one command per line with comments.
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
219 If VERBOSE is `1', put everything on one line. If VERBOSE is omitted
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
220 or nil, use a compact 80-column format."
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
221 (and macro (symbolp macro) (setq macro (symbol-function macro)))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
222 (edmacro-format-keys (or macro last-kbd-macro) verbose))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
223
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
224 ;;; Commands for *Edit Macro* buffer.
109
d649664df7e0 Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
225
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
226 (defun edmacro-finish-edit ()
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
227 (interactive)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
228 (unless (eq major-mode 'edmacro-mode)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
229 (error
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
230 "This command is valid only in buffers created by `edit-kbd-macro'"))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
231 (run-hooks 'edmacro-finish-hook)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
232 (let ((cmd nil) (keys nil) (no-keys nil)
57292
00748c19ee41 Require kmacro to use the new kmacro-lambda-form and
Kim F. Storm <storm@cua.dk>
parents: 52401
diff changeset
233 (mac-counter nil) (mac-format nil) (kmacro nil)
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
234 (top (point-min)))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
235 (goto-char top)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
236 (let ((case-fold-search nil))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
237 (while (cond ((looking-at "[ \t]*\\($\\|;;\\|REM[ \t\n]\\)")
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
238 t)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
239 ((looking-at "Command:[ \t]*\\([^ \t\n]*\\)[ \t]*$")
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
240 (when edmacro-store-hook
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
241 (error "\"Command\" line not allowed in this context"))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
242 (let ((str (buffer-substring (match-beginning 1)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
243 (match-end 1))))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
244 (unless (equal str "")
12955
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
245 (setq cmd (and (not (equal str "none"))
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
246 (intern str)))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
247 (and (fboundp cmd) (not (arrayp (symbol-function cmd)))
57292
00748c19ee41 Require kmacro to use the new kmacro-lambda-form and
Kim F. Storm <storm@cua.dk>
parents: 52401
diff changeset
248 (not (setq kmacro (get cmd 'kmacro)))
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
249 (not (y-or-n-p
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
250 (format "Command %s is already defined; %s"
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
251 cmd "proceed? ")))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
252 (keyboard-quit))))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
253 t)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
254 ((looking-at "Key:\\(.*\\)$")
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
255 (when edmacro-store-hook
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
256 (error "\"Key\" line not allowed in this context"))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
257 (let ((key (edmacro-parse-keys
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
258 (buffer-substring (match-beginning 1)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
259 (match-end 1)))))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
260 (unless (equal key "")
12955
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
261 (if (equal key "none")
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
262 (setq no-keys t)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
263 (push key keys)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
264 (let ((b (key-binding key)))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
265 (and b (commandp b) (not (arrayp b))
57292
00748c19ee41 Require kmacro to use the new kmacro-lambda-form and
Kim F. Storm <storm@cua.dk>
parents: 52401
diff changeset
266 (not (kmacro-extract-lambda b))
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
267 (or (not (fboundp b))
58836
89cc919b0ccd `edit-kbd-macro' is now bound to `C-x C-k e'.
Luc Teirlinck <teirllm@auburn.edu>
parents: 57292
diff changeset
268 (not (or (arrayp (symbol-function b))
89cc919b0ccd `edit-kbd-macro' is now bound to `C-x C-k e'.
Luc Teirlinck <teirllm@auburn.edu>
parents: 57292
diff changeset
269 (get b 'kmacro))))
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
270 (not (y-or-n-p
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
271 (format "Key %s is already defined; %s"
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
272 (edmacro-format-keys key 1)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
273 "proceed? ")))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
274 (keyboard-quit))))))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
275 t)
57292
00748c19ee41 Require kmacro to use the new kmacro-lambda-form and
Kim F. Storm <storm@cua.dk>
parents: 52401
diff changeset
276 ((looking-at "Counter:[ \t]*\\([^ \t\n]*\\)[ \t]*$")
00748c19ee41 Require kmacro to use the new kmacro-lambda-form and
Kim F. Storm <storm@cua.dk>
parents: 52401
diff changeset
277 (when edmacro-store-hook
00748c19ee41 Require kmacro to use the new kmacro-lambda-form and
Kim F. Storm <storm@cua.dk>
parents: 52401
diff changeset
278 (error "\"Counter\" line not allowed in this context"))
00748c19ee41 Require kmacro to use the new kmacro-lambda-form and
Kim F. Storm <storm@cua.dk>
parents: 52401
diff changeset
279 (let ((str (buffer-substring (match-beginning 1)
00748c19ee41 Require kmacro to use the new kmacro-lambda-form and
Kim F. Storm <storm@cua.dk>
parents: 52401
diff changeset
280 (match-end 1))))
00748c19ee41 Require kmacro to use the new kmacro-lambda-form and
Kim F. Storm <storm@cua.dk>
parents: 52401
diff changeset
281 (unless (equal str "")
62402
a7e02ef1e3d6 Replace `string-to-int' by `string-to-number'.
Juanma Barranquero <lekktu@gmail.com>
parents: 58836
diff changeset
282 (setq mac-counter (string-to-number str))))
57292
00748c19ee41 Require kmacro to use the new kmacro-lambda-form and
Kim F. Storm <storm@cua.dk>
parents: 52401
diff changeset
283 t)
00748c19ee41 Require kmacro to use the new kmacro-lambda-form and
Kim F. Storm <storm@cua.dk>
parents: 52401
diff changeset
284 ((looking-at "Format:[ \t]*\"\\([^\n]*\\)\"[ \t]*$")
00748c19ee41 Require kmacro to use the new kmacro-lambda-form and
Kim F. Storm <storm@cua.dk>
parents: 52401
diff changeset
285 (when edmacro-store-hook
00748c19ee41 Require kmacro to use the new kmacro-lambda-form and
Kim F. Storm <storm@cua.dk>
parents: 52401
diff changeset
286 (error "\"Format\" line not allowed in this context"))
00748c19ee41 Require kmacro to use the new kmacro-lambda-form and
Kim F. Storm <storm@cua.dk>
parents: 52401
diff changeset
287 (let ((str (buffer-substring (match-beginning 1)
00748c19ee41 Require kmacro to use the new kmacro-lambda-form and
Kim F. Storm <storm@cua.dk>
parents: 52401
diff changeset
288 (match-end 1))))
00748c19ee41 Require kmacro to use the new kmacro-lambda-form and
Kim F. Storm <storm@cua.dk>
parents: 52401
diff changeset
289 (unless (equal str "")
00748c19ee41 Require kmacro to use the new kmacro-lambda-form and
Kim F. Storm <storm@cua.dk>
parents: 52401
diff changeset
290 (setq mac-format str)))
00748c19ee41 Require kmacro to use the new kmacro-lambda-form and
Kim F. Storm <storm@cua.dk>
parents: 52401
diff changeset
291 t)
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
292 ((looking-at "Macro:[ \t\n]*")
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
293 (goto-char (match-end 0))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
294 nil)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
295 ((eobp) nil)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
296 (t (error "Expected a `Macro:' line")))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
297 (forward-line 1))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
298 (setq top (point)))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
299 (let* ((buf (current-buffer))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
300 (str (buffer-substring top (point-max)))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
301 (modp (buffer-modified-p))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
302 (obuf edmacro-original-buffer)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
303 (store-hook edmacro-store-hook)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
304 (finish-hook edmacro-finish-hook))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
305 (unless (or cmd keys store-hook (equal str ""))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
306 (error "No command name or keys specified"))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
307 (when modp
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
308 (when (buffer-name obuf)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
309 (set-buffer obuf))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
310 (message "Compiling keyboard macro...")
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
311 (let ((mac (edmacro-parse-keys str)))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
312 (message "Compiling keyboard macro...done")
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
313 (if store-hook
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
314 (funcall store-hook mac)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
315 (when (eq cmd 'last-kbd-macro)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
316 (setq last-kbd-macro (and (> (length mac) 0) mac))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
317 (setq cmd nil))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
318 (when cmd
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
319 (if (= (length mac) 0)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
320 (fmakunbound cmd)
57292
00748c19ee41 Require kmacro to use the new kmacro-lambda-form and
Kim F. Storm <storm@cua.dk>
parents: 52401
diff changeset
321 (fset cmd
00748c19ee41 Require kmacro to use the new kmacro-lambda-form and
Kim F. Storm <storm@cua.dk>
parents: 52401
diff changeset
322 (if (and mac-counter mac-format)
00748c19ee41 Require kmacro to use the new kmacro-lambda-form and
Kim F. Storm <storm@cua.dk>
parents: 52401
diff changeset
323 (kmacro-lambda-form mac mac-counter mac-format)
00748c19ee41 Require kmacro to use the new kmacro-lambda-form and
Kim F. Storm <storm@cua.dk>
parents: 52401
diff changeset
324 mac))))
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
325 (if no-keys
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
326 (when cmd
5772
daac61915408 (edit-kbd-macro, edmacro-finish-edit, insert-kbd-macro):
Richard M. Stallman <rms@gnu.org>
parents: 5307
diff changeset
327 (loop for key in (where-is-internal cmd '(keymap)) do
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
328 (global-unset-key key)))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
329 (when keys
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
330 (if (= (length mac) 0)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
331 (loop for key in keys do (global-unset-key key))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
332 (loop for key in keys do
57292
00748c19ee41 Require kmacro to use the new kmacro-lambda-form and
Kim F. Storm <storm@cua.dk>
parents: 52401
diff changeset
333 (global-set-key key
00748c19ee41 Require kmacro to use the new kmacro-lambda-form and
Kim F. Storm <storm@cua.dk>
parents: 52401
diff changeset
334 (or cmd
00748c19ee41 Require kmacro to use the new kmacro-lambda-form and
Kim F. Storm <storm@cua.dk>
parents: 52401
diff changeset
335 (if (and mac-counter mac-format)
00748c19ee41 Require kmacro to use the new kmacro-lambda-form and
Kim F. Storm <storm@cua.dk>
parents: 52401
diff changeset
336 (kmacro-lambda-form mac mac-counter mac-format)
00748c19ee41 Require kmacro to use the new kmacro-lambda-form and
Kim F. Storm <storm@cua.dk>
parents: 52401
diff changeset
337 mac))))))))))
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
338 (kill-buffer buf)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
339 (when (buffer-name obuf)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
340 (switch-to-buffer obuf))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
341 (when finish-hook
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
342 (funcall finish-hook)))))
109
d649664df7e0 Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
343
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
344 (defun edmacro-insert-key (key)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
345 "Insert the written name of a key in the buffer."
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
346 (interactive "kKey to insert: ")
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
347 (if (bolp)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
348 (insert (edmacro-format-keys key t) "\n")
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
349 (insert (edmacro-format-keys key) " ")))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
350
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
351 (defun edmacro-mode ()
99097
8f4ff9c9a49c * edmacro.el (edmacro-eight-bits, edmacro-mode): Fix docstring typos.
Juanma Barranquero <lekktu@gmail.com>
parents: 98621
diff changeset
352 "\\<edmacro-mode-map>Keyboard Macro Editing mode. Press \
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
353 \\[edmacro-finish-edit] to save and exit.
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
354 To abort the edit, just kill this buffer with \\[kill-buffer] RET.
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
355
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
356 Press \\[edmacro-insert-key] to insert the name of any key by typing the key.
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
357
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
358 The editing buffer contains a \"Command:\" line and any number of
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
359 \"Key:\" lines at the top. These are followed by a \"Macro:\" line
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
360 and the macro itself as spelled-out keystrokes: `C-x C-f foo RET'.
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
361
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
362 The \"Command:\" line specifies the command name to which the macro
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
363 is bound, or \"none\" for no command name. Write \"last-kbd-macro\"
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
364 to refer to the current keyboard macro (as used by \\[call-last-kbd-macro]).
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
365
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
366 The \"Key:\" lines specify key sequences to which the macro is bound,
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
367 or \"none\" for no key bindings.
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
368
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
369 You can edit these lines to change the places where the new macro
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
370 is stored.
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
371
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
372
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
373 Format of keyboard macros during editing:
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
374
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
375 Text is divided into \"words\" separated by whitespace. Except for
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
376 the words described below, the characters of each word go directly
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
377 as characters of the macro. The whitespace that separates words
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
378 is ignored. Whitespace in the macro must be written explicitly,
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
379 as in \"foo SPC bar RET\".
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
380
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
381 * The special words RET, SPC, TAB, DEL, LFD, ESC, and NUL represent
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
382 special control characters. The words must be written in uppercase.
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
383
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
384 * A word in angle brackets, e.g., <return>, <down>, or <f1>, represents
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
385 a function key. (Note that in the standard configuration, the
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
386 function key <return> and the control key RET are synonymous.)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
387 You can use angle brackets on the words RET, SPC, etc., but they
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
388 are not required there.
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
389
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
390 * Keys can be written by their ASCII code, using a backslash followed
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
391 by up to six octal digits. This is the only way to represent keys
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
392 with codes above \\377.
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
393
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
394 * One or more prefixes M- (meta), C- (control), S- (shift), A- (alt),
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
395 H- (hyper), and s- (super) may precede a character or key notation.
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
396 For function keys, the prefixes may go inside or outside of the
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
397 brackets: C-<down> = <C-down>. The prefixes may be written in
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
398 any order: M-C-x = C-M-x.
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
399
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
400 Prefixes are not allowed on multi-key words, e.g., C-abc, except
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
401 that the Meta prefix is allowed on a sequence of digits and optional
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
402 minus sign: M--123 = M-- M-1 M-2 M-3.
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
403
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
404 * The `^' notation for control characters also works: ^M = C-m.
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
405
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
406 * Double angle brackets enclose command names: <<next-line>> is
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
407 shorthand for M-x next-line RET.
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
408
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
409 * Finally, REM or ;; causes the rest of the line to be ignored as a
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
410 comment.
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
411
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
412 Any word may be prefixed by a multiplier in the form of a decimal
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
413 number and `*': 3*<right> = <right> <right> <right>, and
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
414 10*foo = foofoofoofoofoofoofoofoofoofoo.
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
415
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
416 Multiple text keys can normally be strung together to form a word,
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
417 but you may need to add whitespace if the word would look like one
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
418 of the above notations: `; ; ;' is a keyboard macro with three
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
419 semicolons, but `;;;' is a comment. Likewise, `\\ 1 2 3' is four
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
420 keys but `\\123' is a single key written in octal, and `< right >'
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
421 is seven keys but `<right>' is a single function key. When in
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
422 doubt, use whitespace."
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
423 (interactive)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
424 (error "This mode can be enabled only by `edit-kbd-macro'"))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
425 (put 'edmacro-mode 'mode-class 'special)
109
d649664df7e0 Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
426
d649664df7e0 Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
427 ;;; Formatting a keyboard macro as human-readable text.
d649664df7e0 Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
428
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
429 (defun edmacro-format-keys (macro &optional verbose)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
430 (setq macro (edmacro-fix-menu-commands macro))
81078
f8e9adbebabb (edmacro-format-keys): Use current-active-maps.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 75347
diff changeset
431 (let* ((maps (current-active-maps))
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
432 (pkeys '(end-macro ?0 ?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9 ?- ?\C-u
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
433 ?\M-- ?\M-0 ?\M-1 ?\M-2 ?\M-3 ?\M-4 ?\M-5 ?\M-6
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
434 ?\M-7 ?\M-8 ?\M-9))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
435 (mdigs (nthcdr 13 pkeys))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
436 (maxkey (if edmacro-eight-bits 255 127))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
437 (case-fold-search nil)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
438 (res-words '("NUL" "TAB" "LFD" "RET" "ESC" "SPC" "DEL" "REM"))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
439 (rest-mac (vconcat macro [end-macro]))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
440 (res "")
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
441 (len 0)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
442 (one-line (eq verbose 1)))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
443 (if one-line (setq verbose nil))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
444 (when (stringp macro)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
445 (loop for i below (length macro) do
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
446 (when (>= (aref rest-mac i) 128)
10692
58ab3325da3b (edmacro-format-keys, edmacro-parse-keys): Don't presume internal bit layout
Karl Heuer <kwzh@gnu.org>
parents: 9199
diff changeset
447 (incf (aref rest-mac i) (- ?\M-\^@ 128)))))
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
448 (while (not (eq (aref rest-mac 0) 'end-macro))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
449 (let* ((prefix
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
450 (or (and (integerp (aref rest-mac 0))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
451 (memq (aref rest-mac 0) mdigs)
12955
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
452 (memq (key-binding (edmacro-subseq rest-mac 0 1))
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
453 '(digit-argument negative-argument))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
454 (let ((i 1))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
455 (while (memq (aref rest-mac i) (cdr mdigs))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
456 (incf i))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
457 (and (not (memq (aref rest-mac i) pkeys))
52131
6be32b5661a6 (edmacro-format-keys): Use edmacro-sanitize-for-string.
Richard M. Stallman <rms@gnu.org>
parents: 49588
diff changeset
458 (prog1 (vconcat "M-" (edmacro-subseq rest-mac 0 i) " ")
12955
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
459 (callf edmacro-subseq rest-mac i)))))
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
460 (and (eq (aref rest-mac 0) ?\C-u)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
461 (eq (key-binding [?\C-u]) 'universal-argument)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
462 (let ((i 1))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
463 (while (eq (aref rest-mac i) ?\C-u)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
464 (incf i))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
465 (and (not (memq (aref rest-mac i) pkeys))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
466 (prog1 (loop repeat i concat "C-u ")
12955
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
467 (callf edmacro-subseq rest-mac i)))))
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
468 (and (eq (aref rest-mac 0) ?\C-u)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
469 (eq (key-binding [?\C-u]) 'universal-argument)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
470 (let ((i 1))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
471 (when (eq (aref rest-mac i) ?-)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
472 (incf i))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
473 (while (memq (aref rest-mac i)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
474 '(?0 ?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
475 (incf i))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
476 (and (not (memq (aref rest-mac i) pkeys))
52131
6be32b5661a6 (edmacro-format-keys): Use edmacro-sanitize-for-string.
Richard M. Stallman <rms@gnu.org>
parents: 49588
diff changeset
477 (prog1 (vconcat "C-u " (edmacro-subseq rest-mac 1 i) " ")
12955
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
478 (callf edmacro-subseq rest-mac i)))))))
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
479 (bind-len (apply 'max 1
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
480 (loop for map in maps
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
481 for b = (lookup-key map rest-mac)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
482 when b collect b)))
12955
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
483 (key (edmacro-subseq rest-mac 0 bind-len))
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
484 (fkey nil) tlen tkey
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
485 (bind (or (loop for map in maps for b = (lookup-key map key)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
486 thereis (and (not (integerp b)) b))
83394
7d093d9d4479 Fix semantics of terminal-local variables. Remove `terminal-local-value' hack.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
487 (and (setq fkey (lookup-key local-function-key-map rest-mac))
12955
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
488 (setq tlen fkey tkey (edmacro-subseq rest-mac 0 tlen)
83394
7d093d9d4479 Fix semantics of terminal-local variables. Remove `terminal-local-value' hack.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
489 fkey (lookup-key local-function-key-map tkey))
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
490 (loop for map in maps
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
491 for b = (lookup-key map fkey)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
492 when (and (not (integerp b)) b)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
493 do (setq bind-len tlen key tkey)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
494 and return b
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
495 finally do (setq fkey nil)))))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
496 (first (aref key 0))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
497 (text (loop for i from bind-len below (length rest-mac)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
498 for ch = (aref rest-mac i)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
499 while (and (integerp ch)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
500 (> ch 32) (< ch maxkey) (/= ch 92)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
501 (eq (key-binding (char-to-string ch))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
502 'self-insert-command)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
503 (or (> i (- (length rest-mac) 2))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
504 (not (eq ch (aref rest-mac (+ i 1))))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
505 (not (eq ch (aref rest-mac (+ i 2))))))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
506 finally return i))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
507 desc)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
508 (if (stringp bind) (setq bind nil))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
509 (cond ((and (eq bind 'self-insert-command) (not prefix)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
510 (> text 1) (integerp first)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
511 (> first 32) (<= first maxkey) (/= first 92)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
512 (progn
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
513 (if (> text 30) (setq text 30))
12955
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
514 (setq desc (concat (edmacro-subseq rest-mac 0 text)))
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
515 (when (string-match "^[ACHMsS]-." desc)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
516 (setq text 2)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
517 (callf substring desc 0 2))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
518 (not (string-match
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
519 "^;;\\|^<.*>$\\|^\\\\[0-9]+$\\|^[0-9]+\\*."
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
520 desc))))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
521 (when (or (string-match "^\\^.$" desc)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
522 (member desc res-words))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
523 (setq desc (mapconcat 'char-to-string desc " ")))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
524 (when verbose
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
525 (setq bind (format "%s * %d" bind text)))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
526 (setq bind-len text))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
527 ((and (eq bind 'execute-extended-command)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
528 (> text bind-len)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
529 (memq (aref rest-mac text) '(return 13))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
530 (progn
12955
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
531 (setq desc (concat (edmacro-subseq rest-mac bind-len text)))
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
532 (commandp (intern-soft desc))))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
533 (if (commandp (intern-soft desc)) (setq bind desc))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
534 (setq desc (format "<<%s>>" desc))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
535 (setq bind-len (1+ text)))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
536 (t
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
537 (setq desc (mapconcat
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
538 (function
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
539 (lambda (ch)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
540 (cond
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
541 ((integerp ch)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
542 (concat
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
543 (loop for pf across "ACHMsS"
10692
58ab3325da3b (edmacro-format-keys, edmacro-parse-keys): Don't presume internal bit layout
Karl Heuer <kwzh@gnu.org>
parents: 9199
diff changeset
544 for bit in '(?\A-\^@ ?\C-\^@ ?\H-\^@
58ab3325da3b (edmacro-format-keys, edmacro-parse-keys): Don't presume internal bit layout
Karl Heuer <kwzh@gnu.org>
parents: 9199
diff changeset
545 ?\M-\^@ ?\s-\^@ ?\S-\^@)
58ab3325da3b (edmacro-format-keys, edmacro-parse-keys): Don't presume internal bit layout
Karl Heuer <kwzh@gnu.org>
parents: 9199
diff changeset
546 when (/= (logand ch bit) 0)
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
547 concat (format "%c-" pf))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
548 (let ((ch2 (logand ch (1- (lsh 1 18)))))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
549 (cond ((<= ch2 32)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
550 (case ch2
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
551 (0 "NUL") (9 "TAB") (10 "LFD")
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
552 (13 "RET") (27 "ESC") (32 "SPC")
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
553 (t
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
554 (format "C-%c"
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
555 (+ (if (<= ch2 26) 96 64)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
556 ch2)))))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
557 ((= ch2 127) "DEL")
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
558 ((<= ch2 maxkey) (char-to-string ch2))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
559 (t (format "\\%o" ch2))))))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
560 ((symbolp ch)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
561 (format "<%s>" ch))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
562 (t
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
563 (error "Unrecognized item in macro: %s" ch)))))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
564 (or fkey key) " "))))
52131
6be32b5661a6 (edmacro-format-keys): Use edmacro-sanitize-for-string.
Richard M. Stallman <rms@gnu.org>
parents: 49588
diff changeset
565 (if prefix
6be32b5661a6 (edmacro-format-keys): Use edmacro-sanitize-for-string.
Richard M. Stallman <rms@gnu.org>
parents: 49588
diff changeset
566 (setq desc (concat (edmacro-sanitize-for-string prefix) desc)))
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
567 (unless (string-match " " desc)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
568 (let ((times 1) (pos bind-len))
12955
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
569 (while (not (edmacro-mismatch rest-mac rest-mac
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
570 0 bind-len pos (+ bind-len pos)))
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
571 (incf times)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
572 (incf pos bind-len))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
573 (when (> times 1)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
574 (setq desc (format "%d*%s" times desc))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
575 (setq bind-len (* bind-len times)))))
12955
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
576 (setq rest-mac (edmacro-subseq rest-mac bind-len))
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
577 (if verbose
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
578 (progn
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
579 (unless (equal res "") (callf concat res "\n"))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
580 (callf concat res desc)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
581 (when (and bind (or (stringp bind) (symbolp bind)))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
582 (callf concat res
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
583 (make-string (max (- 3 (/ (length desc) 8)) 1) 9)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
584 ";; " (if (stringp bind) bind (symbol-name bind))))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
585 (setq len 0))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
586 (if (and (> (+ len (length desc) 2) 72) (not one-line))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
587 (progn
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
588 (callf concat res "\n ")
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
589 (setq len 1))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
590 (unless (equal res "")
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
591 (callf concat res " ")
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
592 (incf len)))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
593 (callf concat res desc)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
594 (incf len (length desc)))))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
595 res))
109
d649664df7e0 Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
596
12955
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
597 (defun edmacro-mismatch (cl-seq1 cl-seq2 cl-start1 cl-end1 cl-start2 cl-end2)
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
598 "Compare SEQ1 with SEQ2, return index of first mismatching element.
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
599 Return nil if the sequences match. If one sequence is a prefix of the
99097
8f4ff9c9a49c * edmacro.el (edmacro-eight-bits, edmacro-mode): Fix docstring typos.
Juanma Barranquero <lekktu@gmail.com>
parents: 98621
diff changeset
600 other, the return value indicates the end of the shorted sequence.
8f4ff9c9a49c * edmacro.el (edmacro-eight-bits, edmacro-mode): Fix docstring typos.
Juanma Barranquero <lekktu@gmail.com>
parents: 98621
diff changeset
601 \n(fn SEQ1 SEQ2 START1 END1 START2 END2)"
12955
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
602 (let (cl-test cl-test-not cl-key cl-from-end)
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
603 (or cl-end1 (setq cl-end1 (length cl-seq1)))
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
604 (or cl-end2 (setq cl-end2 (length cl-seq2)))
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
605 (if cl-from-end
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
606 (progn
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
607 (while (and (< cl-start1 cl-end1) (< cl-start2 cl-end2)
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
608 (cl-check-match (elt cl-seq1 (1- cl-end1))
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
609 (elt cl-seq2 (1- cl-end2))))
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
610 (setq cl-end1 (1- cl-end1) cl-end2 (1- cl-end2)))
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
611 (and (or (< cl-start1 cl-end1) (< cl-start2 cl-end2))
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
612 (1- cl-end1)))
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
613 (let ((cl-p1 (and (listp cl-seq1) (nthcdr cl-start1 cl-seq1)))
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
614 (cl-p2 (and (listp cl-seq2) (nthcdr cl-start2 cl-seq2))))
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
615 (while (and (< cl-start1 cl-end1) (< cl-start2 cl-end2)
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
616 (cl-check-match (if cl-p1 (car cl-p1)
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
617 (aref cl-seq1 cl-start1))
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
618 (if cl-p2 (car cl-p2)
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
619 (aref cl-seq2 cl-start2))))
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
620 (setq cl-p1 (cdr cl-p1) cl-p2 (cdr cl-p2)
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
621 cl-start1 (1+ cl-start1) cl-start2 (1+ cl-start2)))
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
622 (and (or (< cl-start1 cl-end1) (< cl-start2 cl-end2))
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
623 cl-start1)))))
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
624
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
625 (defun edmacro-subseq (seq start &optional end)
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
626 "Return the subsequence of SEQ from START to END.
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
627 If END is omitted, it defaults to the length of the sequence.
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
628 If START or END is negative, it counts from the end."
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
629 (if (stringp seq) (substring seq start end)
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
630 (let (len)
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
631 (and end (< end 0) (setq end (+ end (setq len (length seq)))))
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
632 (if (< start 0) (setq start (+ start (or len (setq len (length seq))))))
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
633 (cond ((listp seq)
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
634 (if (> start 0) (setq seq (nthcdr start seq)))
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
635 (if end
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
636 (let ((res nil))
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
637 (while (>= (setq end (1- end)) start)
47294
15e9f75f55b0 (edmacro-subseq): Don't use cl-push/cl-pop.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47197
diff changeset
638 (push (pop seq) res))
12955
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
639 (nreverse res))
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
640 (copy-sequence seq)))
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
641 (t
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
642 (or end (setq end (or len (length seq))))
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
643 (let ((res (make-vector (max (- end start) 0) nil))
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
644 (i 0))
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
645 (while (< start end)
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
646 (aset res i (aref seq start))
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
647 (setq i (1+ i) start (1+ start)))
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
648 res))))))
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
649
52131
6be32b5661a6 (edmacro-format-keys): Use edmacro-sanitize-for-string.
Richard M. Stallman <rms@gnu.org>
parents: 49588
diff changeset
650 (defun edmacro-sanitize-for-string (seq)
99097
8f4ff9c9a49c * edmacro.el (edmacro-eight-bits, edmacro-mode): Fix docstring typos.
Juanma Barranquero <lekktu@gmail.com>
parents: 98621
diff changeset
651 "Convert a key sequence vector SEQ into a string.
52131
6be32b5661a6 (edmacro-format-keys): Use edmacro-sanitize-for-string.
Richard M. Stallman <rms@gnu.org>
parents: 49588
diff changeset
652 The string represents the same events; Meta is indicated by bit 7.
6be32b5661a6 (edmacro-format-keys): Use edmacro-sanitize-for-string.
Richard M. Stallman <rms@gnu.org>
parents: 49588
diff changeset
653 This function assumes that the events can be stored in a string."
6be32b5661a6 (edmacro-format-keys): Use edmacro-sanitize-for-string.
Richard M. Stallman <rms@gnu.org>
parents: 49588
diff changeset
654 (setq seq (copy-sequence seq))
6be32b5661a6 (edmacro-format-keys): Use edmacro-sanitize-for-string.
Richard M. Stallman <rms@gnu.org>
parents: 49588
diff changeset
655 (loop for i below (length seq) do
58836
89cc919b0ccd `edit-kbd-macro' is now bound to `C-x C-k e'.
Luc Teirlinck <teirllm@auburn.edu>
parents: 57292
diff changeset
656 (when (logand (aref seq i) 128)
52131
6be32b5661a6 (edmacro-format-keys): Use edmacro-sanitize-for-string.
Richard M. Stallman <rms@gnu.org>
parents: 49588
diff changeset
657 (setf (aref seq i) (logand (aref seq i) 127))))
6be32b5661a6 (edmacro-format-keys): Use edmacro-sanitize-for-string.
Richard M. Stallman <rms@gnu.org>
parents: 49588
diff changeset
658 seq)
6be32b5661a6 (edmacro-format-keys): Use edmacro-sanitize-for-string.
Richard M. Stallman <rms@gnu.org>
parents: 49588
diff changeset
659
45939
6ccb89338ab1 (edmacro-fix-menu-commands):
Richard M. Stallman <rms@gnu.org>
parents: 38436
diff changeset
660 (defun edmacro-fix-menu-commands (macro &optional noerror)
6ccb89338ab1 (edmacro-fix-menu-commands):
Richard M. Stallman <rms@gnu.org>
parents: 38436
diff changeset
661 (if (vectorp macro)
6ccb89338ab1 (edmacro-fix-menu-commands):
Richard M. Stallman <rms@gnu.org>
parents: 38436
diff changeset
662 (let (result)
6ccb89338ab1 (edmacro-fix-menu-commands):
Richard M. Stallman <rms@gnu.org>
parents: 38436
diff changeset
663 ;; Make a list of the elements.
6ccb89338ab1 (edmacro-fix-menu-commands):
Richard M. Stallman <rms@gnu.org>
parents: 38436
diff changeset
664 (setq macro (append macro nil))
6ccb89338ab1 (edmacro-fix-menu-commands):
Richard M. Stallman <rms@gnu.org>
parents: 38436
diff changeset
665 (dolist (ev macro)
6ccb89338ab1 (edmacro-fix-menu-commands):
Richard M. Stallman <rms@gnu.org>
parents: 38436
diff changeset
666 (cond ((atom ev)
6ccb89338ab1 (edmacro-fix-menu-commands):
Richard M. Stallman <rms@gnu.org>
parents: 38436
diff changeset
667 (push ev result))
6ccb89338ab1 (edmacro-fix-menu-commands):
Richard M. Stallman <rms@gnu.org>
parents: 38436
diff changeset
668 ((eq (car ev) 'help-echo))
72246
c3cdfa41017b (edmacro-fix-menu-commands): Ignore switch-frame.
Kim F. Storm <storm@cua.dk>
parents: 68651
diff changeset
669 ((eq (car ev) 'switch-frame))
45939
6ccb89338ab1 (edmacro-fix-menu-commands):
Richard M. Stallman <rms@gnu.org>
parents: 38436
diff changeset
670 ((equal ev '(menu-bar))
6ccb89338ab1 (edmacro-fix-menu-commands):
Richard M. Stallman <rms@gnu.org>
parents: 38436
diff changeset
671 (push 'menu-bar result))
6ccb89338ab1 (edmacro-fix-menu-commands):
Richard M. Stallman <rms@gnu.org>
parents: 38436
diff changeset
672 ((equal (cadadr ev) '(menu-bar))
6ccb89338ab1 (edmacro-fix-menu-commands):
Richard M. Stallman <rms@gnu.org>
parents: 38436
diff changeset
673 (push (vector 'menu-bar (car ev)) result))
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
674 ;; It would be nice to do pop-up menus, too, but not enough
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
675 ;; info is recorded in macros to make this possible.
45939
6ccb89338ab1 (edmacro-fix-menu-commands):
Richard M. Stallman <rms@gnu.org>
parents: 38436
diff changeset
676 (noerror
6ccb89338ab1 (edmacro-fix-menu-commands):
Richard M. Stallman <rms@gnu.org>
parents: 38436
diff changeset
677 ;; Just ignore mouse events.
6ccb89338ab1 (edmacro-fix-menu-commands):
Richard M. Stallman <rms@gnu.org>
parents: 38436
diff changeset
678 nil)
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
679 (t
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
680 (error "Macros with mouse clicks are not %s"
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
681 "supported by this command"))))
45939
6ccb89338ab1 (edmacro-fix-menu-commands):
Richard M. Stallman <rms@gnu.org>
parents: 38436
diff changeset
682 ;; Reverse them again and make them back into a vector.
6ccb89338ab1 (edmacro-fix-menu-commands):
Richard M. Stallman <rms@gnu.org>
parents: 38436
diff changeset
683 (vconcat (nreverse result)))
6ccb89338ab1 (edmacro-fix-menu-commands):
Richard M. Stallman <rms@gnu.org>
parents: 38436
diff changeset
684 macro))
109
d649664df7e0 Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
685
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
686 ;;; Parsing a human-readable keyboard macro.
109
d649664df7e0 Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
687
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
688 (defun edmacro-parse-keys (string &optional need-vector)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
689 (let ((case-fold-search nil)
97565
1b5f78ffef83 (edmacro-parse-keys): Catch events with spaces in their names.
Chong Yidong <cyd@stupidchicken.com>
parents: 94678
diff changeset
690 (len (length string)) ; We won't alter string in the loop below.
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
691 (pos 0)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
692 (res []))
97565
1b5f78ffef83 (edmacro-parse-keys): Catch events with spaces in their names.
Chong Yidong <cyd@stupidchicken.com>
parents: 94678
diff changeset
693 (while (and (< pos len)
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
694 (string-match "[^ \t\n\f]+" string pos))
97565
1b5f78ffef83 (edmacro-parse-keys): Catch events with spaces in their names.
Chong Yidong <cyd@stupidchicken.com>
parents: 94678
diff changeset
695 (let* ((word-beg (match-beginning 0))
1b5f78ffef83 (edmacro-parse-keys): Catch events with spaces in their names.
Chong Yidong <cyd@stupidchicken.com>
parents: 94678
diff changeset
696 (word-end (match-end 0))
1b5f78ffef83 (edmacro-parse-keys): Catch events with spaces in their names.
Chong Yidong <cyd@stupidchicken.com>
parents: 94678
diff changeset
697 (word (substring string word-beg len))
1b5f78ffef83 (edmacro-parse-keys): Catch events with spaces in their names.
Chong Yidong <cyd@stupidchicken.com>
parents: 94678
diff changeset
698 (times 1)
1b5f78ffef83 (edmacro-parse-keys): Catch events with spaces in their names.
Chong Yidong <cyd@stupidchicken.com>
parents: 94678
diff changeset
699 key)
1b5f78ffef83 (edmacro-parse-keys): Catch events with spaces in their names.
Chong Yidong <cyd@stupidchicken.com>
parents: 94678
diff changeset
700 ;; Try to catch events of the form "<as df>".
103298
70832a352a9c * edmacro.el (edmacro-parse-keys): Fix 2008-08-19 change (Bug#3387).
Chong Yidong <cyd@stupidchicken.com>
parents: 100908
diff changeset
701 (if (string-match "\\`<[^ <>\t\n\f][^>\t\n\f]*>" word)
97565
1b5f78ffef83 (edmacro-parse-keys): Catch events with spaces in their names.
Chong Yidong <cyd@stupidchicken.com>
parents: 94678
diff changeset
702 (setq word (match-string 0 word)
1b5f78ffef83 (edmacro-parse-keys): Catch events with spaces in their names.
Chong Yidong <cyd@stupidchicken.com>
parents: 94678
diff changeset
703 pos (+ word-beg (match-end 0)))
1b5f78ffef83 (edmacro-parse-keys): Catch events with spaces in their names.
Chong Yidong <cyd@stupidchicken.com>
parents: 94678
diff changeset
704 (setq word (substring string word-beg word-end)
1b5f78ffef83 (edmacro-parse-keys): Catch events with spaces in their names.
Chong Yidong <cyd@stupidchicken.com>
parents: 94678
diff changeset
705 pos word-end))
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
706 (when (string-match "\\([0-9]+\\)\\*." word)
62402
a7e02ef1e3d6 Replace `string-to-int' by `string-to-number'.
Juanma Barranquero <lekktu@gmail.com>
parents: 58836
diff changeset
707 (setq times (string-to-number (substring word 0 (match-end 1))))
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
708 (setq word (substring word (1+ (match-end 1)))))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
709 (cond ((string-match "^<<.+>>$" word)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
710 (setq key (vconcat (if (eq (key-binding [?\M-x])
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
711 'execute-extended-command)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
712 [?\M-x]
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
713 (or (car (where-is-internal
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
714 'execute-extended-command))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
715 [?\M-x]))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
716 (substring word 2 -2) "\r")))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
717 ((and (string-match "^\\(\\([ACHMsS]-\\)*\\)<\\(.+\\)>$" word)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
718 (progn
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
719 (setq word (concat (substring word (match-beginning 1)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
720 (match-end 1))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
721 (substring word (match-beginning 3)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
722 (match-end 3))))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
723 (not (string-match
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
724 "\\<\\(NUL\\|RET\\|LFD\\|ESC\\|SPC\\|DEL\\)$"
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
725 word))))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
726 (setq key (list (intern word))))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
727 ((or (equal word "REM") (string-match "^;;" word))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
728 (setq pos (string-match "$" string pos)))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
729 (t
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
730 (let ((orig-word word) (prefix 0) (bits 0))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
731 (while (string-match "^[ACHMsS]-." word)
10692
58ab3325da3b (edmacro-format-keys, edmacro-parse-keys): Don't presume internal bit layout
Karl Heuer <kwzh@gnu.org>
parents: 9199
diff changeset
732 (incf bits (cdr (assq (aref word 0)
58ab3325da3b (edmacro-format-keys, edmacro-parse-keys): Don't presume internal bit layout
Karl Heuer <kwzh@gnu.org>
parents: 9199
diff changeset
733 '((?A . ?\A-\^@) (?C . ?\C-\^@)
58ab3325da3b (edmacro-format-keys, edmacro-parse-keys): Don't presume internal bit layout
Karl Heuer <kwzh@gnu.org>
parents: 9199
diff changeset
734 (?H . ?\H-\^@) (?M . ?\M-\^@)
58ab3325da3b (edmacro-format-keys, edmacro-parse-keys): Don't presume internal bit layout
Karl Heuer <kwzh@gnu.org>
parents: 9199
diff changeset
735 (?s . ?\s-\^@) (?S . ?\S-\^@)))))
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
736 (incf prefix 2)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
737 (callf substring word 2))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
738 (when (string-match "^\\^.$" word)
10692
58ab3325da3b (edmacro-format-keys, edmacro-parse-keys): Don't presume internal bit layout
Karl Heuer <kwzh@gnu.org>
parents: 9199
diff changeset
739 (incf bits ?\C-\^@)
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
740 (incf prefix)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
741 (callf substring word 1))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
742 (let ((found (assoc word '(("NUL" . "\0") ("RET" . "\r")
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
743 ("LFD" . "\n") ("TAB" . "\t")
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
744 ("ESC" . "\e") ("SPC" . " ")
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
745 ("DEL" . "\177")))))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
746 (when found (setq word (cdr found))))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
747 (when (string-match "^\\\\[0-7]+$" word)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
748 (loop for ch across word
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
749 for n = 0 then (+ (* n 8) ch -48)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
750 finally do (setq word (vector n))))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
751 (cond ((= bits 0)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
752 (setq key word))
10692
58ab3325da3b (edmacro-format-keys, edmacro-parse-keys): Don't presume internal bit layout
Karl Heuer <kwzh@gnu.org>
parents: 9199
diff changeset
753 ((and (= bits ?\M-\^@) (stringp word)
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
754 (string-match "^-?[0-9]+$" word))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
755 (setq key (loop for x across word collect (+ x bits))))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
756 ((/= (length word) 1)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
757 (error "%s must prefix a single character, not %s"
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
758 (substring orig-word 0 prefix) word))
10692
58ab3325da3b (edmacro-format-keys, edmacro-parse-keys): Don't presume internal bit layout
Karl Heuer <kwzh@gnu.org>
parents: 9199
diff changeset
759 ((and (/= (logand bits ?\C-\^@) 0) (stringp word)
16951
156fd377c7d0 (edmacro-parse-keys): Don't treat C-. or C-? as ASCII control char.
Richard M. Stallman <rms@gnu.org>
parents: 16283
diff changeset
760 ;; We used to accept . and ? here,
156fd377c7d0 (edmacro-parse-keys): Don't treat C-. or C-? as ASCII control char.
Richard M. Stallman <rms@gnu.org>
parents: 16283
diff changeset
761 ;; but . is simply wrong,
156fd377c7d0 (edmacro-parse-keys): Don't treat C-. or C-? as ASCII control char.
Richard M. Stallman <rms@gnu.org>
parents: 16283
diff changeset
762 ;; and C-? is not used (we use DEL instead).
156fd377c7d0 (edmacro-parse-keys): Don't treat C-. or C-? as ASCII control char.
Richard M. Stallman <rms@gnu.org>
parents: 16283
diff changeset
763 (string-match "[@-_a-z]" word))
10692
58ab3325da3b (edmacro-format-keys, edmacro-parse-keys): Don't presume internal bit layout
Karl Heuer <kwzh@gnu.org>
parents: 9199
diff changeset
764 (setq key (list (+ bits (- ?\C-\^@)
16977
e97bdda07a30 (edmacro-parse-keys): Remove redundant test for ?.
Erik Naggum <erik@naggum.no>
parents: 16951
diff changeset
765 (logand (aref word 0) 31)))))
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
766 (t
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
767 (setq key (list (+ bits (aref word 0)))))))))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
768 (when key
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
769 (loop repeat times do (callf vconcat res key)))))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
770 (when (and (>= (length res) 4)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
771 (eq (aref res 0) ?\C-x)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
772 (eq (aref res 1) ?\()
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
773 (eq (aref res (- (length res) 2)) ?\C-x)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
774 (eq (aref res (- (length res) 1)) ?\)))
12955
2e80892d4b39 Load cl only during compilation.
Richard M. Stallman <rms@gnu.org>
parents: 11870
diff changeset
775 (setq res (edmacro-subseq res 2 -2)))
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
776 (if (and (not need-vector)
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
777 (loop for ch across res
89493
add0d115c419 (edmacro-parse-keys): Use characterp.
Dave Love <fx@gnu.org>
parents: 88123
diff changeset
778 always (and (characterp ch)
10692
58ab3325da3b (edmacro-format-keys, edmacro-parse-keys): Don't presume internal bit layout
Karl Heuer <kwzh@gnu.org>
parents: 9199
diff changeset
779 (let ((ch2 (logand ch (lognot ?\M-\^@))))
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
780 (and (>= ch2 0) (<= ch2 127))))))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
781 (concat (loop for ch across res
10692
58ab3325da3b (edmacro-format-keys, edmacro-parse-keys): Don't presume internal bit layout
Karl Heuer <kwzh@gnu.org>
parents: 9199
diff changeset
782 collect (if (= (logand ch ?\M-\^@) 0)
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
783 ch (+ ch 128))))
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
784 res)))
109
d649664df7e0 Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
785
4754
463663a999ee Total rewrite by Gillespie.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
786 (provide 'edmacro)
662
8a533acedb77 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 258
diff changeset
787
8a533acedb77 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 258
diff changeset
788 ;;; edmacro.el ends here