Mercurial > emacs
annotate lisp/wdired.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 |
rev | line source |
---|---|
55098 | 1 ;;; wdired.el --- Rename files editing their names in dired buffers |
2 | |
112218
376148b31b5e
Add 2011 to FSF/AIST copyright years.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
3 ;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 |
101010
4efc7ca085ce
Replace last-command-char with last-command-event.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
4 ;; Free Software Foundation, Inc. |
55098 | 5 |
6 ;; Filename: wdired.el | |
61350
796b7fe4bfd8
(wdired-advise-functions, wdired-add-skip-in-replace)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
61030
diff
changeset
|
7 ;; Author: Juan León Lahoz García <juanleon1@gmail.com> |
796b7fe4bfd8
(wdired-advise-functions, wdired-add-skip-in-replace)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
61030
diff
changeset
|
8 ;; Version: 2.0 |
55098 | 9 ;; Keywords: dired, environment, files, renaming |
10 | |
11 ;; This file is part of GNU Emacs. | |
12 | |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
91898
diff
changeset
|
13 ;; GNU Emacs is free software: you can redistribute it and/or modify |
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
91898
diff
changeset
|
14 ;; it under the terms of the GNU General Public License as published by |
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
91898
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:
91898
diff
changeset
|
16 ;; (at your option) any later version. |
55098 | 17 |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
91898
diff
changeset
|
18 ;; GNU Emacs is distributed in the hope that it will be useful, |
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
91898
diff
changeset
|
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
91898
diff
changeset
|
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
91898
diff
changeset
|
21 ;; GNU General Public License for more details. |
55098 | 22 |
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:
91898
diff
changeset
|
24 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
55098 | 25 |
26 ;;; Commentary: | |
27 | |
28 ;; wdired.el (the "w" is for writable) provides an alternative way of | |
29 ;; renaming files. | |
30 ;; | |
31 ;; Have you ever wished to use C-x r t (string-rectangle), M-% | |
68680
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
32 ;; (query-replace), M-c (capitalize-word), etc... to change the name of |
61473 | 33 ;; the files in a "dired" buffer? Now you can do this. All the power |
34 ;; of Emacs commands are available to renaming files! | |
68680
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
35 ;; |
55098 | 36 ;; This package provides a function that makes the filenames of a a |
37 ;; dired buffer editable, by changing the buffer mode (which inhibits | |
38 ;; all of the commands of dired mode). Here you can edit the names of | |
39 ;; one or more files and directories, and when you press C-c C-c, the | |
40 ;; renaming takes effect and you are back to dired mode. | |
41 ;; | |
61473 | 42 ;; Another things you can do with WDired: |
55098 | 43 ;; |
44 ;; - To move files to another directory (by typing their path, | |
45 ;; absolute or relative, as a part of the new filename). | |
46 ;; | |
47 ;; - To change the target of symbolic links. | |
48 ;; | |
49 ;; - To change the permission bits of the filenames (in systems with a | |
50 ;; working unix-alike `dired-chmod-program'). See and customize the | |
61473 | 51 ;; variable `wdired-allow-to-change-permissions'. To change a single |
55098 | 52 ;; char (toggling between its two more usual values) you can press |
61473 | 53 ;; the space bar over it or left-click the mouse. To set any char to |
55098 | 54 ;; an specific value (this includes the SUID, SGID and STI bits) you |
61473 | 55 ;; can use the key labeled as the letter you want. Please note that |
55098 | 56 ;; permissions of the links cannot be changed in that way, because |
57 ;; the change would affect to their targets, and this would not be | |
58 ;; WYSIWYG :-). | |
59 ;; | |
60 ;; - To mark files for deletion, by deleting their whole filename. | |
61 | |
62 ;;; Installation: | |
63 | |
64 ;; Add this file (byte-compiling it is recommended) to your load-path. | |
65 ;; Then add one of these set of lines (or similar ones) to your config: | |
66 ;; | |
67 ;; This is the easy way: | |
68 ;; | |
69 ;; (require 'wdired) | |
70 ;; (define-key dired-mode-map "r" 'wdired-change-to-wdired-mode) | |
71 ;; | |
61473 | 72 ;; This is the recommended way for faster Emacs startup time and lower |
73 ;; memory consumption: | |
55098 | 74 ;; |
75 ;; (autoload 'wdired-change-to-wdired-mode "wdired") | |
61473 | 76 ;; (eval-after-load "dired" |
55098 | 77 ;; '(lambda () |
78 ;; (define-key dired-mode-map "r" 'wdired-change-to-wdired-mode) | |
79 ;; (define-key dired-mode-map | |
80 ;; [menu-bar immediate wdired-change-to-wdired-mode] | |
81 ;; '("Edit File Names" . wdired-change-to-wdired-mode)))) | |
82 ;; | |
61473 | 83 ;; Type "M-x customize-group RET wdired" if you want to make changes |
84 ;; to the default behavior. | |
55098 | 85 |
86 ;;; Usage: | |
87 | |
88 ;; Then, you can start editing the names of the files by typing "r" | |
89 ;; (or whatever key you choose, or M-x wdired-change-to-wdired-mode). | |
90 ;; Use C-c C-c when finished or C-c C-k to abort. You can use also the | |
91 ;; menu options: in dired mode, "Edit File Names" under "Immediate". | |
92 ;; While editing the names, a new submenu "WDired" is available at top | |
93 ;; level. You can customize the behavior of this package from this | |
94 ;; menu. | |
95 | |
96 ;;; Change Log: | |
97 | |
61473 | 98 ;; Google is your friend (previous versions with complete changelogs |
99 ;; were posted to gnu.emacs.sources) | |
55098 | 100 |
101 ;;; Code: | |
102 | |
61473 | 103 (defvar dired-backup-overwrite) ; Only in Emacs 20.x this is a custom var |
55098 | 104 |
69279
45a2e01db282
(toplevel): Require `cl' at compile-time.
John Paul Wallington <jpw@pobox.com>
parents:
68680
diff
changeset
|
105 (eval-when-compile (require 'cl)) |
68680
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
106 (require 'dired) |
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
107 (autoload 'dired-do-create-files-regexp "dired-aux") |
55098 | 108 |
109 (defgroup wdired nil | |
110 "Mode to rename files by editing their names in dired buffers." | |
111 :group 'dired) | |
112 | |
113 (defcustom wdired-use-interactive-rename nil | |
68680
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
114 "If non-nil, WDired requires confirmation before actually renaming files. |
61473 | 115 If nil, WDired doesn't require confirmation to change the file names, |
116 and the variable `wdired-confirm-overwrite' controls whether it is ok | |
117 to overwrite files without asking." | |
55098 | 118 :type 'boolean |
119 :group 'wdired) | |
120 | |
61473 | 121 (defcustom wdired-confirm-overwrite t |
68680
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
122 "If nil the renames can overwrite files without asking. |
61473 | 123 This variable has no effect at all if `wdired-use-interactive-rename' |
124 is not nil." | |
55098 | 125 :type 'boolean |
126 :group 'wdired) | |
127 | |
61473 | 128 (defcustom wdired-use-dired-vertical-movement nil |
68680
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
129 "If t, the \"up\" and \"down\" movement works as in Dired mode. |
55098 | 130 That is, always move the point to the beginning of the filename at line. |
131 | |
85930
68bf07bd1f57
(wdired-use-dired-vertical-movement): Doc fix.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
85747
diff
changeset
|
132 If `sometimes', only move to the beginning of filename if the point is |
68bf07bd1f57
(wdired-use-dired-vertical-movement): Doc fix.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
85747
diff
changeset
|
133 before it, and `track-eol' is non-nil. This behavior is very handy |
55098 | 134 when editing several filenames. |
135 | |
136 If nil, \"up\" and \"down\" movement is done as in any other buffer." | |
137 :type '(choice (const :tag "As in any other mode" nil) | |
138 (const :tag "Smart cursor placement" sometimes) | |
139 (other :tag "As in dired mode" t)) | |
140 :group 'wdired) | |
141 | |
142 (defcustom wdired-allow-to-redirect-links t | |
68680
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
143 "If non-nil, the target of the symbolic links are editable. |
55098 | 144 In systems without symbolic links support, this variable has no effect |
145 at all." | |
146 :type 'boolean | |
147 :group 'wdired) | |
148 | |
149 (defcustom wdired-allow-to-change-permissions nil | |
68680
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
150 "If non-nil, the permissions bits of the files are editable. |
55098 | 151 |
152 If t, to change a single bit, put the cursor over it and press the | |
153 space bar, or left click over it. You can also hit the letter you want | |
154 to set: if this value is allowed, the character in the buffer will be | |
155 changed. Anyway, the point is advanced one position, so, for example, | |
61473 | 156 you can keep the <x> key pressed to give execution permissions to |
55098 | 157 everybody to that file. |
158 | |
91898
cd55489e649a
(wdired-allow-to-change-permissions): Fix typo.
Michaël Cadilhac <michael.cadilhac@lrde.org>
parents:
88003
diff
changeset
|
159 If `advanced', the bits are freely editable. You can use |
55098 | 160 `string-rectangle', `query-replace', etc. You can put any value (even |
161 newlines), but if you want your changes to be useful, you better put a | |
162 intelligible value. | |
163 | |
61473 | 164 Anyway, the real change of the permissions is done by the external |
55098 | 165 program `dired-chmod-program', which must exist." |
166 :type '(choice (const :tag "Not allowed" nil) | |
55109
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
167 (const :tag "Toggle/set bits" t) |
55098 | 168 (other :tag "Bits freely editable" advanced)) |
169 :group 'wdired) | |
170 | |
55109
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
171 (defvar wdired-mode-map |
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
172 (let ((map (make-sparse-keymap))) |
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
173 (define-key map "\C-x\C-s" 'wdired-finish-edit) |
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
174 (define-key map "\C-c\C-c" 'wdired-finish-edit) |
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
175 (define-key map "\C-c\C-k" 'wdired-abort-changes) |
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
176 (define-key map "\C-c\C-[" 'wdired-abort-changes) |
82194
06241457c4f0
(wdired-exit): New function.
Juri Linkov <juri@jurta.org>
parents:
82140
diff
changeset
|
177 (define-key map "\C-x\C-q" 'wdired-exit) |
61473 | 178 (define-key map "\C-m" 'ignore) |
179 (define-key map "\C-j" 'ignore) | |
180 (define-key map "\C-o" 'ignore) | |
55109
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
181 (define-key map [up] 'wdired-previous-line) |
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
182 (define-key map "\C-p" 'wdired-previous-line) |
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
183 (define-key map [down] 'wdired-next-line) |
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
184 (define-key map "\C-n" 'wdired-next-line) |
55098 | 185 |
55109
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
186 (define-key map [menu-bar wdired] |
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
187 (cons "WDired" (make-sparse-keymap "WDired"))) |
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
188 (define-key map [menu-bar wdired wdired-customize] |
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
189 '("Options" . wdired-customize)) |
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
190 (define-key map [menu-bar wdired dashes] |
55098 | 191 '("--")) |
55109
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
192 (define-key map [menu-bar wdired wdired-abort-changes] |
68152
3a7458f9152d
(wdired-mode-map): Add help echo for wdired-abort-changes.
Nick Roberts <nickrob@snap.net.nz>
parents:
67561
diff
changeset
|
193 '(menu-item "Abort Changes" wdired-abort-changes |
3a7458f9152d
(wdired-mode-map): Add help echo for wdired-abort-changes.
Nick Roberts <nickrob@snap.net.nz>
parents:
67561
diff
changeset
|
194 :help "Abort changes and return to dired mode")) |
55109
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
195 (define-key map [menu-bar wdired wdired-finish-edit] |
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
196 '("Commit Changes" . wdired-finish-edit)) |
68680
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
197 |
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
198 (define-key map [remap upcase-word] 'wdired-upcase-word) |
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
199 (define-key map [remap capitalize-word] 'wdired-capitalize-word) |
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
200 (define-key map [remap downcase-word] 'wdired-downcase-word) |
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
201 |
55109
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
202 map)) |
55098 | 203 |
55109
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
204 (defvar wdired-mode-hook nil |
61473 | 205 "Hooks run when changing to WDired mode.") |
55098 | 206 |
207 ;; Local variables (put here to avoid compilation gripes) | |
208 (defvar wdired-col-perm) ;; Column where the permission bits start | |
209 (defvar wdired-old-content) | |
67561
827930ad591b
(wdired-old-point): New internal variable.
Juri Linkov <juri@jurta.org>
parents:
65582
diff
changeset
|
210 (defvar wdired-old-point) |
55098 | 211 |
212 | |
213 (defun wdired-mode () | |
214 "\\<wdired-mode-map>File Names Editing mode. | |
215 | |
61473 | 216 Press \\[wdired-finish-edit] to make the changes to take effect |
217 and exit. To abort the edit, use \\[wdired-abort-changes]. | |
55098 | 218 |
61473 | 219 In this mode you can edit the names of the files, the target of |
220 the links and the permission bits of the files. You can use | |
221 \\[customize-group] RET wdired to customize WDired behavior. | |
55098 | 222 |
61473 | 223 The only editable texts in a WDired buffer are filenames, |
224 symbolic link targets, and filenames permission." | |
55098 | 225 (interactive) |
226 (error "This mode can be enabled only by `wdired-change-to-wdired-mode'")) | |
227 (put 'wdired-mode 'mode-class 'special) | |
228 | |
229 | |
230 ;;;###autoload | |
231 (defun wdired-change-to-wdired-mode () | |
232 "Put a dired buffer in a mode in which filenames are editable. | |
61473 | 233 \\<wdired-mode-map> |
234 This mode allows the user to change the names of the files, and after | |
235 typing \\[wdired-finish-edit] Emacs renames the files and directories | |
236 in disk. | |
55098 | 237 |
238 See `wdired-mode'." | |
239 (interactive) | |
72160
183934d15fbb
(wdired-change-to-wdired-mode, wdired-change-to-dired-mode):
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
69279
diff
changeset
|
240 (or (eq major-mode 'dired-mode) |
183934d15fbb
(wdired-change-to-wdired-mode, wdired-change-to-dired-mode):
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
69279
diff
changeset
|
241 (error "Not a Dired buffer")) |
55098 | 242 (set (make-local-variable 'wdired-old-content) |
243 (buffer-substring (point-min) (point-max))) | |
67561
827930ad591b
(wdired-old-point): New internal variable.
Juri Linkov <juri@jurta.org>
parents:
65582
diff
changeset
|
244 (set (make-local-variable 'wdired-old-point) (point)) |
61350
796b7fe4bfd8
(wdired-advise-functions, wdired-add-skip-in-replace)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
61030
diff
changeset
|
245 (set (make-local-variable 'query-replace-skip-read-only) t) |
55098 | 246 (use-local-map wdired-mode-map) |
55109
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
247 (force-mode-line-update) |
55098 | 248 (setq buffer-read-only nil) |
249 (dired-unadvertise default-directory) | |
250 (add-hook 'kill-buffer-hook 'wdired-check-kill-buffer nil t) | |
251 (setq major-mode 'wdired-mode) | |
61473 | 252 (setq mode-name "Editable Dired") |
55098 | 253 (setq revert-buffer-function 'wdired-revert) |
254 ;; I temp disable undo for performance: since I'm going to clear the | |
255 ;; undo list, it can save more than a 9% of time with big | |
256 ;; directories because setting properties modify the undo-list. | |
257 (buffer-disable-undo) | |
258 (wdired-preprocess-files) | |
259 (if wdired-allow-to-change-permissions | |
260 (wdired-preprocess-perms)) | |
261 (if (and wdired-allow-to-redirect-links (fboundp 'make-symbolic-link)) | |
262 (wdired-preprocess-symlinks)) | |
263 (buffer-enable-undo) ; Performance hack. See above. | |
264 (set-buffer-modified-p nil) | |
265 (setq buffer-undo-list nil) | |
62746
0fe5c8d2cd65
(wdired-change-to-wdired-mode): Use run-mode-hooks.
Lute Kamstra <lute@gnu.org>
parents:
61473
diff
changeset
|
266 (run-mode-hooks 'wdired-mode-hook) |
67561
827930ad591b
(wdired-old-point): New internal variable.
Juri Linkov <juri@jurta.org>
parents:
65582
diff
changeset
|
267 (message "%s" (substitute-command-keys |
827930ad591b
(wdired-old-point): New internal variable.
Juri Linkov <juri@jurta.org>
parents:
65582
diff
changeset
|
268 "Press \\[wdired-finish-edit] when finished \ |
61030
6b0506554db8
(wdired-change-to-wdired-mode):
Juri Linkov <juri@jurta.org>
parents:
60141
diff
changeset
|
269 or \\[wdired-abort-changes] to abort changes"))) |
55098 | 270 |
271 | |
272 ;; Protect the buffer so only the filenames can be changed, and put | |
273 ;; properties so filenames (old and new) can be easily found. | |
274 (defun wdired-preprocess-files () | |
95915
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
275 (put-text-property (point-min) (1+ (point-min))'front-sticky t) |
55098 | 276 (save-excursion |
277 (goto-char (point-min)) | |
278 (let ((b-protection (point)) | |
279 filename) | |
280 (while (not (eobp)) | |
281 (setq filename (dired-get-filename nil t)) | |
55109
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
282 (when (and filename |
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
283 (not (member (file-name-nondirectory filename) '("." "..")))) |
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
284 (dired-move-to-filename) |
74526
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
285 ;; The rear-nonsticky property below shall ensure that text preceding |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
286 ;; the filename can't be modified. |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
287 (add-text-properties |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
288 (1- (point)) (point) `(old-name ,filename rear-nonsticky (read-only))) |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
289 (put-text-property b-protection (point) 'read-only t) |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
290 (setq b-protection (dired-move-to-end-of-filename t)) |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
291 (put-text-property (point) (1+ (point)) 'end-name t)) |
55098 | 292 (forward-line)) |
293 (put-text-property b-protection (point-max) 'read-only t)))) | |
294 | |
295 ;; This code is a copy of some dired-get-filename lines. | |
296 (defsubst wdired-normalize-filename (file) | |
297 (setq file | |
55109
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
298 ;; FIXME: shouldn't we check for a `b' argument or somesuch before |
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
299 ;; doing such unquoting? --Stef |
55098 | 300 (read (concat |
55109
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
301 "\"" (replace-regexp-in-string |
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
302 "\\([^\\]\\|\\`\\)\"" "\\1\\\\\"" file) |
55098 | 303 "\""))) |
304 (and file buffer-file-coding-system | |
305 (not file-name-coding-system) | |
306 (not default-file-name-coding-system) | |
307 (setq file (encode-coding-string file buffer-file-coding-system))) | |
308 file) | |
309 | |
310 (defun wdired-get-filename (&optional no-dir old) | |
311 "Return the filename at line. | |
55109
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
312 Similar to `dired-get-filename' but it doesn't rely on regexps. It |
61473 | 313 relies on WDired buffer's properties. Optional arg NO-DIR with value |
55098 | 314 non-nil means don't include directory. Optional arg OLD with value |
315 non-nil means return old filename." | |
55109
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
316 ;; FIXME: Use dired-get-filename's new properties. |
74526
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
317 (let (beg end file) |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
318 (save-excursion |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
319 (setq end (line-end-position)) |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
320 (beginning-of-line) |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
321 (setq beg (next-single-property-change (point) 'old-name nil end)) |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
322 (unless (eq beg end) |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
323 (if old |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
324 (setq file (get-text-property beg 'old-name)) |
88003
fa9ef03eaf25
(wdired-get-filename): Change `(1+ beg)' to `beg' so
Martin Rudalics <rudalics@gmx.at>
parents:
87649
diff
changeset
|
325 ;; In the following form changed `(1+ beg)' to `beg' so that |
fa9ef03eaf25
(wdired-get-filename): Change `(1+ beg)' to `beg' so
Martin Rudalics <rudalics@gmx.at>
parents:
87649
diff
changeset
|
326 ;; the filename end is found even when the filename is empty. |
fa9ef03eaf25
(wdired-get-filename): Change `(1+ beg)' to `beg' so
Martin Rudalics <rudalics@gmx.at>
parents:
87649
diff
changeset
|
327 ;; Fixes error and spurious newlines when marking files for |
fa9ef03eaf25
(wdired-get-filename): Change `(1+ beg)' to `beg' so
Martin Rudalics <rudalics@gmx.at>
parents:
87649
diff
changeset
|
328 ;; deletion. |
fa9ef03eaf25
(wdired-get-filename): Change `(1+ beg)' to `beg' so
Martin Rudalics <rudalics@gmx.at>
parents:
87649
diff
changeset
|
329 (setq end (next-single-property-change beg 'end-name)) |
74526
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
330 (setq file (buffer-substring-no-properties (1+ beg) end))) |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
331 (and file (setq file (wdired-normalize-filename file)))) |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
332 (if (or no-dir old) |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
333 file |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
334 (and file (> (length file) 0) |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
335 (concat (dired-current-directory) file)))))) |
55098 | 336 |
337 | |
338 (defun wdired-change-to-dired-mode () | |
339 "Change the mode back to dired." | |
72160
183934d15fbb
(wdired-change-to-wdired-mode, wdired-change-to-dired-mode):
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
69279
diff
changeset
|
340 (or (eq major-mode 'wdired-mode) |
183934d15fbb
(wdired-change-to-wdired-mode, wdired-change-to-dired-mode):
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
69279
diff
changeset
|
341 (error "Not a Wdired buffer")) |
55098 | 342 (let ((inhibit-read-only t)) |
74526
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
343 (remove-text-properties |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
344 (point-min) (point-max) |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
345 '(front-sticky nil rear-nonsticky nil read-only nil keymap nil))) |
55098 | 346 (use-local-map dired-mode-map) |
55109
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
347 (force-mode-line-update) |
55098 | 348 (setq buffer-read-only t) |
349 (setq major-mode 'dired-mode) | |
350 (setq mode-name "Dired") | |
351 (dired-advertise) | |
352 (remove-hook 'kill-buffer-hook 'wdired-check-kill-buffer t) | |
68680
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
353 (set (make-local-variable 'revert-buffer-function) 'dired-revert)) |
55098 | 354 |
355 | |
356 (defun wdired-abort-changes () | |
357 "Abort changes and return to dired mode." | |
358 (interactive) | |
359 (let ((inhibit-read-only t)) | |
360 (erase-buffer) | |
67561
827930ad591b
(wdired-old-point): New internal variable.
Juri Linkov <juri@jurta.org>
parents:
65582
diff
changeset
|
361 (insert wdired-old-content) |
827930ad591b
(wdired-old-point): New internal variable.
Juri Linkov <juri@jurta.org>
parents:
65582
diff
changeset
|
362 (goto-char wdired-old-point)) |
55098 | 363 (wdired-change-to-dired-mode) |
364 (set-buffer-modified-p nil) | |
55371
a96e9558b1ea
(wdired-change-to-wdired-mode): Quote wdired-mode-hook in run-hooks.
Lars Hansen <larsh@soem.dk>
parents:
55109
diff
changeset
|
365 (setq buffer-undo-list nil) |
a96e9558b1ea
(wdired-change-to-wdired-mode): Quote wdired-mode-hook in run-hooks.
Lars Hansen <larsh@soem.dk>
parents:
55109
diff
changeset
|
366 (message "Changes aborted")) |
55098 | 367 |
368 (defun wdired-finish-edit () | |
369 "Actually rename files based on your editing in the Dired buffer." | |
370 (interactive) | |
371 (wdired-change-to-dired-mode) | |
95915
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
372 (let ((changes nil) |
55098 | 373 (errors 0) |
100066
96fae56a7d72
(wdired-finish-edit): If displaying a single file, change
Chong Yidong <cyd@stupidchicken.com>
parents:
97581
diff
changeset
|
374 files-deleted |
96fae56a7d72
(wdired-finish-edit): If displaying a single file, change
Chong Yidong <cyd@stupidchicken.com>
parents:
97581
diff
changeset
|
375 files-renamed |
96fae56a7d72
(wdired-finish-edit): If displaying a single file, change
Chong Yidong <cyd@stupidchicken.com>
parents:
97581
diff
changeset
|
376 some-file-names-unchanged |
96fae56a7d72
(wdired-finish-edit): If displaying a single file, change
Chong Yidong <cyd@stupidchicken.com>
parents:
97581
diff
changeset
|
377 file-old file-new tmp-value) |
55098 | 378 (save-excursion |
74526
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
379 (when (and wdired-allow-to-redirect-links |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
380 (fboundp 'make-symbolic-link)) |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
381 (setq tmp-value (wdired-do-symlink-changes)) |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
382 (setq errors (cdr tmp-value)) |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
383 (setq changes (car tmp-value))) |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
384 (when (and wdired-allow-to-change-permissions |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
385 (boundp 'wdired-col-perm)) ; could have been changed |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
386 (setq tmp-value (wdired-do-perm-changes)) |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
387 (setq errors (+ errors (cdr tmp-value))) |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
388 (setq changes (or changes (car tmp-value)))) |
55098 | 389 (goto-char (point-max)) |
390 (while (not (bobp)) | |
100066
96fae56a7d72
(wdired-finish-edit): If displaying a single file, change
Chong Yidong <cyd@stupidchicken.com>
parents:
97581
diff
changeset
|
391 (setq file-old (wdired-get-filename nil t)) |
96fae56a7d72
(wdired-finish-edit): If displaying a single file, change
Chong Yidong <cyd@stupidchicken.com>
parents:
97581
diff
changeset
|
392 (when file-old |
95915
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
393 (setq file-new (wdired-get-filename)) |
100066
96fae56a7d72
(wdired-finish-edit): If displaying a single file, change
Chong Yidong <cyd@stupidchicken.com>
parents:
97581
diff
changeset
|
394 (if (equal file-new file-old) |
96fae56a7d72
(wdired-finish-edit): If displaying a single file, change
Chong Yidong <cyd@stupidchicken.com>
parents:
97581
diff
changeset
|
395 (setq some-file-names-unchanged t) |
95915
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
396 (setq changes t) |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
397 (if (not file-new) ;empty filename! |
100066
96fae56a7d72
(wdired-finish-edit): If displaying a single file, change
Chong Yidong <cyd@stupidchicken.com>
parents:
97581
diff
changeset
|
398 (push file-old files-deleted) |
96fae56a7d72
(wdired-finish-edit): If displaying a single file, change
Chong Yidong <cyd@stupidchicken.com>
parents:
97581
diff
changeset
|
399 (push (cons file-old (substitute-in-file-name file-new)) |
96fae56a7d72
(wdired-finish-edit): If displaying a single file, change
Chong Yidong <cyd@stupidchicken.com>
parents:
97581
diff
changeset
|
400 files-renamed)))) |
55098 | 401 (forward-line -1))) |
100066
96fae56a7d72
(wdired-finish-edit): If displaying a single file, change
Chong Yidong <cyd@stupidchicken.com>
parents:
97581
diff
changeset
|
402 (when files-renamed |
96fae56a7d72
(wdired-finish-edit): If displaying a single file, change
Chong Yidong <cyd@stupidchicken.com>
parents:
97581
diff
changeset
|
403 (setq errors (+ errors (wdired-do-renames files-renamed)))) |
55098 | 404 (if changes |
100066
96fae56a7d72
(wdired-finish-edit): If displaying a single file, change
Chong Yidong <cyd@stupidchicken.com>
parents:
97581
diff
changeset
|
405 (progn |
96fae56a7d72
(wdired-finish-edit): If displaying a single file, change
Chong Yidong <cyd@stupidchicken.com>
parents:
97581
diff
changeset
|
406 ;; If we are displaying a single file (rather than the |
96fae56a7d72
(wdired-finish-edit): If displaying a single file, change
Chong Yidong <cyd@stupidchicken.com>
parents:
97581
diff
changeset
|
407 ;; contents of a directory), change dired-directory if that |
96fae56a7d72
(wdired-finish-edit): If displaying a single file, change
Chong Yidong <cyd@stupidchicken.com>
parents:
97581
diff
changeset
|
408 ;; file was renamed. (This ought to be generalized to |
96fae56a7d72
(wdired-finish-edit): If displaying a single file, change
Chong Yidong <cyd@stupidchicken.com>
parents:
97581
diff
changeset
|
409 ;; handle the multiple files case, but that's less trivial). |
96fae56a7d72
(wdired-finish-edit): If displaying a single file, change
Chong Yidong <cyd@stupidchicken.com>
parents:
97581
diff
changeset
|
410 (when (and (stringp dired-directory) |
96fae56a7d72
(wdired-finish-edit): If displaying a single file, change
Chong Yidong <cyd@stupidchicken.com>
parents:
97581
diff
changeset
|
411 (not (file-directory-p dired-directory)) |
96fae56a7d72
(wdired-finish-edit): If displaying a single file, change
Chong Yidong <cyd@stupidchicken.com>
parents:
97581
diff
changeset
|
412 (null some-file-names-unchanged) |
96fae56a7d72
(wdired-finish-edit): If displaying a single file, change
Chong Yidong <cyd@stupidchicken.com>
parents:
97581
diff
changeset
|
413 (= (length files-renamed) 1)) |
96fae56a7d72
(wdired-finish-edit): If displaying a single file, change
Chong Yidong <cyd@stupidchicken.com>
parents:
97581
diff
changeset
|
414 (setq dired-directory (cdr (car files-renamed)))) |
96fae56a7d72
(wdired-finish-edit): If displaying a single file, change
Chong Yidong <cyd@stupidchicken.com>
parents:
97581
diff
changeset
|
415 ;; Re-sort the buffer. |
96fae56a7d72
(wdired-finish-edit): If displaying a single file, change
Chong Yidong <cyd@stupidchicken.com>
parents:
97581
diff
changeset
|
416 (revert-buffer)) |
68680
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
417 (let ((inhibit-read-only t)) |
55098 | 418 (remove-text-properties (point-min) (point-max) |
419 '(old-name nil end-name nil old-link nil | |
420 end-link nil end-perm nil | |
421 old-perm nil perm-changed nil)) | |
422 (message "(No changes to be performed)"))) | |
74526
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
423 (when files-deleted |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
424 (wdired-flag-for-deletion files-deleted)) |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
425 (when (> errors 0) |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
426 (dired-log-summary (format "%d rename actions failed" errors) nil))) |
55098 | 427 (set-buffer-modified-p nil) |
428 (setq buffer-undo-list nil)) | |
429 | |
95915
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
430 (defun wdired-do-renames (renames) |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
431 "Perform RENAMES in parallel." |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
432 (let ((residue ()) |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
433 (progress nil) |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
434 (errors 0) |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
435 (overwrite (or (not wdired-confirm-overwrite) 1))) |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
436 (while (or renames |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
437 ;; We've done one round through the renames, we have found |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
438 ;; some residue, but we also made some progress, so maybe |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
439 ;; some of the residue were resolved: try again. |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
440 (prog1 (setq renames residue) |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
441 (setq progress nil) |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
442 (setq residue nil))) |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
443 (let* ((rename (pop renames)) |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
444 (file-new (cdr rename))) |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
445 (cond |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
446 ((rassoc file-new renames) |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
447 (error "Trying to rename 2 files to the same name")) |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
448 ((assoc file-new renames) |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
449 ;; Renaming to a file name that already exists but will itself be |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
450 ;; renamed as well. Let's wait until that one gets renamed. |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
451 (push rename residue)) |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
452 ((and (assoc file-new residue) |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
453 ;; Make sure the file really exists: if it doesn't it's |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
454 ;; not really a conflict. It might be a temp-file generated |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
455 ;; specifically to break a circular renaming. |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
456 (file-exists-p file-new)) |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
457 ;; Renaming to a file name that already exists, needed to be renamed, |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
458 ;; but whose renaming could not be performed right away. |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
459 (if (or progress renames) |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
460 ;; There's still a chance the conflict will be resolved. |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
461 (push rename residue) |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
462 ;; We have not made any progress and we've reached the end of |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
463 ;; the renames, so we really have a circular conflict, and we |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
464 ;; have to forcefully break the cycle. |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
465 (message "Circular renaming: using temporary file name") |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
466 (let ((tmp (make-temp-name file-new))) |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
467 (push (cons (car rename) tmp) renames) |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
468 (push (cons tmp file-new) residue)))) |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
469 (t |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
470 (setq progress t) |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
471 (let ((file-ori (car rename))) |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
472 (if wdired-use-interactive-rename |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
473 (wdired-search-and-rename file-ori file-new) |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
474 ;; If dired-rename-file autoloads dired-aux while |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
475 ;; dired-backup-overwrite is locally bound, |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
476 ;; dired-backup-overwrite won't be initialized. |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
477 ;; So we must ensure dired-aux is loaded. |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
478 (require 'dired-aux) |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
479 (condition-case err |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
480 (let ((dired-backup-overwrite nil)) |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
481 (dired-rename-file file-ori file-new |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
482 overwrite)) |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
483 (error |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
484 (setq errors (1+ errors)) |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
485 (dired-log (concat "Rename `" file-ori "' to `" |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
486 file-new "' failed:\n%s\n") |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
487 err))))))))) |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
488 errors)) |
105170 | 489 |
95915
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
490 |
82194
06241457c4f0
(wdired-exit): New function.
Juri Linkov <juri@jurta.org>
parents:
82140
diff
changeset
|
491 (defun wdired-exit () |
06241457c4f0
(wdired-exit): New function.
Juri Linkov <juri@jurta.org>
parents:
82140
diff
changeset
|
492 "Exit wdired and return to dired mode. |
06241457c4f0
(wdired-exit): New function.
Juri Linkov <juri@jurta.org>
parents:
82140
diff
changeset
|
493 Just return to dired mode if there are no changes. Otherwise, |
06241457c4f0
(wdired-exit): New function.
Juri Linkov <juri@jurta.org>
parents:
82140
diff
changeset
|
494 ask a yes-or-no question whether to save or cancel changes, |
06241457c4f0
(wdired-exit): New function.
Juri Linkov <juri@jurta.org>
parents:
82140
diff
changeset
|
495 and proceed depending on the answer." |
06241457c4f0
(wdired-exit): New function.
Juri Linkov <juri@jurta.org>
parents:
82140
diff
changeset
|
496 (interactive) |
06241457c4f0
(wdired-exit): New function.
Juri Linkov <juri@jurta.org>
parents:
82140
diff
changeset
|
497 (if (buffer-modified-p) |
06241457c4f0
(wdired-exit): New function.
Juri Linkov <juri@jurta.org>
parents:
82140
diff
changeset
|
498 (if (y-or-n-p (format "Buffer %s modified; save changes? " |
06241457c4f0
(wdired-exit): New function.
Juri Linkov <juri@jurta.org>
parents:
82140
diff
changeset
|
499 (current-buffer))) |
06241457c4f0
(wdired-exit): New function.
Juri Linkov <juri@jurta.org>
parents:
82140
diff
changeset
|
500 (wdired-finish-edit) |
06241457c4f0
(wdired-exit): New function.
Juri Linkov <juri@jurta.org>
parents:
82140
diff
changeset
|
501 (wdired-abort-changes)) |
06241457c4f0
(wdired-exit): New function.
Juri Linkov <juri@jurta.org>
parents:
82140
diff
changeset
|
502 (wdired-change-to-dired-mode) |
06241457c4f0
(wdired-exit): New function.
Juri Linkov <juri@jurta.org>
parents:
82140
diff
changeset
|
503 (set-buffer-modified-p nil) |
06241457c4f0
(wdired-exit): New function.
Juri Linkov <juri@jurta.org>
parents:
82140
diff
changeset
|
504 (setq buffer-undo-list nil) |
06241457c4f0
(wdired-exit): New function.
Juri Linkov <juri@jurta.org>
parents:
82140
diff
changeset
|
505 (message "(No changes need to be saved)"))) |
06241457c4f0
(wdired-exit): New function.
Juri Linkov <juri@jurta.org>
parents:
82140
diff
changeset
|
506 |
68680
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
507 ;; Rename a file, searching it in a modified dired buffer, in order |
55098 | 508 ;; to be able to use `dired-do-create-files-regexp' and get its |
68680
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
509 ;; "benefits". |
55098 | 510 (defun wdired-search-and-rename (filename-ori filename-new) |
511 (save-excursion | |
512 (goto-char (point-max)) | |
513 (forward-line -1) | |
95915
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
514 (let ((done nil) |
55098 | 515 curr-filename) |
95915
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
516 (while (and (not done) (not (bobp))) |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
517 (setq curr-filename (wdired-get-filename nil t)) |
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
518 (if (equal curr-filename filename-ori) |
55098 | 519 (progn |
95957
42fbae40c9e0
(wdired-search-and-rename): Fix undocumented change.
Andreas Schwab <schwab@suse.de>
parents:
95915
diff
changeset
|
520 (setq done t) |
55098 | 521 (let ((inhibit-read-only t)) |
522 (dired-move-to-filename) | |
523 (search-forward (wdired-get-filename t) nil t) | |
524 (replace-match (file-name-nondirectory filename-ori) t t)) | |
525 (dired-do-create-files-regexp | |
526 (function dired-rename-file) | |
527 "Move" 1 ".*" filename-new nil t)) | |
95915
80ae3c334377
(wdired-do-renames): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
528 (forward-line -1)))))) |
55098 | 529 |
530 ;; marks a list of files for deletion | |
531 (defun wdired-flag-for-deletion (filenames-ori) | |
532 (save-excursion | |
533 (goto-char (point-min)) | |
534 (while (not (eobp)) | |
535 (if (member (dired-get-filename nil t) filenames-ori) | |
536 (dired-flag-file-deletion 1) | |
537 (forward-line))))) | |
538 | |
539 (defun wdired-customize () | |
61473 | 540 "Customize WDired options." |
55098 | 541 (interactive) |
542 (customize-apropos "wdired" 'groups)) | |
543 | |
544 (defun wdired-revert (&optional arg noconfirm) | |
61473 | 545 "Discard changes in the buffer and update it based on changes on disk. |
546 Optional arguments are ignored." | |
55098 | 547 (wdired-change-to-dired-mode) |
548 (revert-buffer) | |
549 (wdired-change-to-wdired-mode)) | |
550 | |
551 (defun wdired-check-kill-buffer () | |
55109
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
552 ;; FIXME: Can't we use the normal mechanism for that? --Stef |
55098 | 553 (if (and |
554 (buffer-modified-p) | |
555 (not (y-or-n-p "Buffer changed. Discard changes and kill buffer? "))) | |
105170 | 556 (error "Error"))) |
55098 | 557 |
558 (defun wdired-next-line (arg) | |
559 "Move down lines then position at filename or the current column. | |
61473 | 560 See `wdired-use-dired-vertical-movement'. Optional prefix ARG |
55098 | 561 says how many lines to move; default is one line." |
562 (interactive "p") | |
85747
6a503e26cfe8
(wdired-next-line, wdired-previous-line): Use
Martin Rudalics <rudalics@gmx.at>
parents:
85478
diff
changeset
|
563 (with-no-warnings (next-line arg)) |
61473 | 564 (if (or (eq wdired-use-dired-vertical-movement t) |
565 (and wdired-use-dired-vertical-movement | |
55098 | 566 (< (current-column) |
567 (save-excursion (dired-move-to-filename) | |
568 (current-column))))) | |
569 (dired-move-to-filename))) | |
570 | |
571 (defun wdired-previous-line (arg) | |
572 "Move up lines then position at filename or the current column. | |
61473 | 573 See `wdired-use-dired-vertical-movement'. Optional prefix ARG |
55098 | 574 says how many lines to move; default is one line." |
575 (interactive "p") | |
85747
6a503e26cfe8
(wdired-next-line, wdired-previous-line): Use
Martin Rudalics <rudalics@gmx.at>
parents:
85478
diff
changeset
|
576 (with-no-warnings (previous-line arg)) |
61473 | 577 (if (or (eq wdired-use-dired-vertical-movement t) |
578 (and wdired-use-dired-vertical-movement | |
55098 | 579 (< (current-column) |
580 (save-excursion (dired-move-to-filename) | |
581 (current-column))))) | |
582 (dired-move-to-filename))) | |
583 | |
584 ;; Put the needed properties to allow the user to change links' targets | |
585 (defun wdired-preprocess-symlinks () | |
586 (let ((inhibit-read-only t)) | |
587 (save-excursion | |
588 (goto-char (point-min)) | |
589 (while (not (eobp)) | |
590 (if (looking-at dired-re-sym) | |
591 (progn | |
592 (re-search-forward " -> \\(.*\\)$") | |
593 (put-text-property (- (match-beginning 1) 2) | |
594 (1- (match-beginning 1)) 'old-link | |
595 (match-string-no-properties 1)) | |
596 (put-text-property (match-end 1) (1+ (match-end 1)) 'end-link t) | |
74528
6be933449565
(wdired-preprocess-symlinks): Make the spaces after symlink arrows
Chong Yidong <cyd@stupidchicken.com>
parents:
74526
diff
changeset
|
597 (put-text-property (1- (match-beginning 1)) |
6be933449565
(wdired-preprocess-symlinks): Make the spaces after symlink arrows
Chong Yidong <cyd@stupidchicken.com>
parents:
74526
diff
changeset
|
598 (match-beginning 1) |
6be933449565
(wdired-preprocess-symlinks): Make the spaces after symlink arrows
Chong Yidong <cyd@stupidchicken.com>
parents:
74526
diff
changeset
|
599 'rear-nonsticky '(read-only)) |
6be933449565
(wdired-preprocess-symlinks): Make the spaces after symlink arrows
Chong Yidong <cyd@stupidchicken.com>
parents:
74526
diff
changeset
|
600 (put-text-property (match-beginning 1) |
55098 | 601 (match-end 1) 'read-only nil))) |
602 (forward-line) | |
603 (beginning-of-line))))) | |
604 | |
605 | |
606 (defun wdired-get-previous-link (&optional old move) | |
607 "Return the next symlink target. | |
608 If OLD, return the old target. If MOVE, move point before it." | |
74526
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
609 (let (beg end target) |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
610 (setq beg (previous-single-property-change (point) 'old-link nil)) |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
611 (if beg |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
612 (progn |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
613 (if old |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
614 (setq target (get-text-property (1- beg) 'old-link)) |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
615 (setq end (next-single-property-change beg 'end-link)) |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
616 (setq target (buffer-substring-no-properties (1+ beg) end))) |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
617 (if move (goto-char (1- beg))))) |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
618 (and target (wdired-normalize-filename target)))) |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
619 |
86324
6a97b0f7d704
(make-symbolic-link): Declare as function.
Juanma Barranquero <lekktu@gmail.com>
parents:
85930
diff
changeset
|
620 (declare-function make-symbolic-link "fileio.c") |
55098 | 621 |
622 ;; Perform the changes in the target of the changed links. | |
68680
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
623 (defun wdired-do-symlink-changes () |
55098 | 624 (let ((changes nil) |
625 (errors 0) | |
626 link-to-ori link-to-new link-from) | |
627 (goto-char (point-max)) | |
628 (while (setq link-to-new (wdired-get-previous-link)) | |
629 (setq link-to-ori (wdired-get-previous-link t t)) | |
630 (setq link-from (wdired-get-filename nil t)) | |
68680
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
631 (unless (equal link-to-new link-to-ori) |
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
632 (setq changes t) |
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
633 (if (equal link-to-new "") ;empty filename! |
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
634 (setq link-to-new "/dev/null")) |
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
635 (condition-case err |
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
636 (progn |
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
637 (delete-file link-from) |
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
638 (make-symbolic-link |
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
639 (substitute-in-file-name link-to-new) link-from)) |
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
640 (error |
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
641 (setq errors (1+ errors)) |
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
642 (dired-log (concat "Link `" link-from "' to `" |
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
643 link-to-new "' failed:\n%s\n") |
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
644 err))))) |
55098 | 645 (cons changes errors))) |
646 | |
647 ;; Perform a "case command" skipping read-only words. | |
648 (defun wdired-xcase-word (command arg) | |
649 (if (< arg 0) | |
650 (funcall command arg) | |
68680
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
651 (while (> arg 0) |
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
652 (condition-case err |
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
653 (progn |
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
654 (funcall command 1) |
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
655 (setq arg (1- arg))) |
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
656 (error |
75159
21d0aec573ef
(wdired-xcase-word): Skip non-word read-only characters.
Martin Rudalics <rudalics@gmx.at>
parents:
74528
diff
changeset
|
657 (if (forward-word) |
21d0aec573ef
(wdired-xcase-word): Skip non-word read-only characters.
Martin Rudalics <rudalics@gmx.at>
parents:
74528
diff
changeset
|
658 ;; Skip any non-word characters to avoid triggering a read-only |
21d0aec573ef
(wdired-xcase-word): Skip non-word read-only characters.
Martin Rudalics <rudalics@gmx.at>
parents:
74528
diff
changeset
|
659 ;; error which would cause skipping the next word characters too. |
21d0aec573ef
(wdired-xcase-word): Skip non-word read-only characters.
Martin Rudalics <rudalics@gmx.at>
parents:
74528
diff
changeset
|
660 (skip-syntax-forward "^w") |
21d0aec573ef
(wdired-xcase-word): Skip non-word read-only characters.
Martin Rudalics <rudalics@gmx.at>
parents:
74528
diff
changeset
|
661 (setq arg 0))))))) |
55098 | 662 |
663 (defun wdired-downcase-word (arg) | |
61473 | 664 "WDired version of `downcase-word'. |
55098 | 665 Like original function but it skips read-only words." |
666 (interactive "p") | |
667 (wdired-xcase-word 'downcase-word arg)) | |
668 | |
669 (defun wdired-upcase-word (arg) | |
61473 | 670 "WDired version of `upcase-word'. |
55098 | 671 Like original function but it skips read-only words." |
672 (interactive "p") | |
673 (wdired-xcase-word 'upcase-word arg)) | |
674 | |
675 (defun wdired-capitalize-word (arg) | |
61473 | 676 "WDired version of `capitalize-word'. |
55098 | 677 Like original function but it skips read-only words." |
678 (interactive "p") | |
679 (wdired-xcase-word 'capitalize-word arg)) | |
680 | |
681 | |
682 ;; The following code deals with changing the access bits (or | |
683 ;; permissions) of the files. | |
684 | |
68680
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
685 (defvar wdired-perm-mode-map |
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
686 (let ((map (make-sparse-keymap))) |
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
687 (define-key map " " 'wdired-toggle-bit) |
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
688 (define-key map "r" 'wdired-set-bit) |
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
689 (define-key map "w" 'wdired-set-bit) |
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
690 (define-key map "x" 'wdired-set-bit) |
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
691 (define-key map "-" 'wdired-set-bit) |
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
692 (define-key map "S" 'wdired-set-bit) |
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
693 (define-key map "s" 'wdired-set-bit) |
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
694 (define-key map "T" 'wdired-set-bit) |
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
695 (define-key map "t" 'wdired-set-bit) |
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
696 (define-key map "s" 'wdired-set-bit) |
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
697 (define-key map "l" 'wdired-set-bit) |
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
698 (define-key map [down-mouse-1] 'wdired-mouse-toggle-bit) |
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
699 map)) |
55098 | 700 |
74526
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
701 ;; Put a keymap property to the permission bits of the files, and store the |
55098 | 702 ;; original name and permissions as a property |
68680
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
703 (defun wdired-preprocess-perms () |
74526
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
704 (let ((inhibit-read-only t)) |
55098 | 705 (set (make-local-variable 'wdired-col-perm) nil) |
706 (save-excursion | |
707 (goto-char (point-min)) | |
708 (while (not (eobp)) | |
74526
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
709 (when (and (not (looking-at dired-re-sym)) |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
710 (wdired-get-filename) |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
711 (re-search-forward dired-re-perms (line-end-position) 'eol)) |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
712 (let ((begin (match-beginning 0)) |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
713 (end (match-end 0))) |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
714 (unless wdired-col-perm |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
715 (setq wdired-col-perm (- (current-column) 9))) |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
716 (if (eq wdired-allow-to-change-permissions 'advanced) |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
717 (progn |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
718 (put-text-property begin end 'read-only nil) |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
719 ;; make first permission bit writable |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
720 (put-text-property |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
721 (1- begin) begin 'rear-nonsticky '(read-only))) |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
722 ;; avoid that keymap applies to text following permissions |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
723 (add-text-properties |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
724 (1+ begin) end |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
725 `(keymap ,wdired-perm-mode-map rear-nonsticky (keymap)))) |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
726 (put-text-property end (1+ end) 'end-perm t) |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
727 (put-text-property |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
728 begin (1+ begin) 'old-perm (match-string-no-properties 0)))) |
55098 | 729 (forward-line) |
730 (beginning-of-line))))) | |
731 | |
732 (defun wdired-perm-allowed-in-pos (char pos) | |
733 (cond | |
734 ((= char ?-) t) | |
735 ((= char ?r) (= (% pos 3) 0)) | |
736 ((= char ?w) (= (% pos 3) 1)) | |
737 ((= char ?x) (= (% pos 3) 2)) | |
738 ((memq char '(?s ?S)) (memq pos '(2 5))) | |
739 ((memq char '(?t ?T)) (= pos 8)) | |
740 ((= char ?l) (= pos 5)))) | |
741 | |
742 (defun wdired-set-bit () | |
743 "Set a permission bit character." | |
744 (interactive) | |
101010
4efc7ca085ce
Replace last-command-char with last-command-event.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
745 (if (wdired-perm-allowed-in-pos last-command-event |
55098 | 746 (- (current-column) wdired-col-perm)) |
101010
4efc7ca085ce
Replace last-command-char with last-command-event.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
747 (let ((new-bit (char-to-string last-command-event)) |
55098 | 748 (inhibit-read-only t) |
749 (pos-prop (- (point) (- (current-column) wdired-col-perm)))) | |
68680
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
750 (put-text-property 0 1 'keymap wdired-perm-mode-map new-bit) |
55098 | 751 (put-text-property 0 1 'read-only t new-bit) |
752 (insert new-bit) | |
753 (delete-char 1) | |
74526
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
754 (put-text-property (1- pos-prop) pos-prop 'perm-changed t) |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
755 (put-text-property (1- (point)) (point) 'rear-nonsticky '(keymap))) |
55098 | 756 (forward-char 1))) |
757 | |
68680
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
758 (defun wdired-toggle-bit () |
55098 | 759 "Toggle the permission bit at point." |
760 (interactive) | |
761 (let ((inhibit-read-only t) | |
74526
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
762 (new-bit "-") |
55098 | 763 (pos-prop (- (point) (- (current-column) wdired-col-perm)))) |
74526
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
764 (if (eq (char-after (point)) ?-) |
81639
8e5203081e80
* dired-aux.el: Remove `dired-call-process'.
Michael Albinus <michael.albinus@gmx.de>
parents:
75347
diff
changeset
|
765 (setq new-bit |
74526
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
766 (if (= (% (- (current-column) wdired-col-perm) 3) 0) "r" |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
767 (if (= (% (- (current-column) wdired-col-perm) 3) 1) "w" |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
768 "x")))) |
68680
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
769 (put-text-property 0 1 'keymap wdired-perm-mode-map new-bit) |
55098 | 770 (put-text-property 0 1 'read-only t new-bit) |
771 (insert new-bit) | |
772 (delete-char 1) | |
74526
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
773 (put-text-property (1- pos-prop) pos-prop 'perm-changed t) |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
774 (put-text-property (1- (point)) (point) 'rear-nonsticky '(keymap)))) |
55098 | 775 |
776 (defun wdired-mouse-toggle-bit (event) | |
777 "Toggle the permission bit that was left clicked." | |
778 (interactive "e") | |
779 (mouse-set-point event) | |
780 (wdired-toggle-bit)) | |
781 | |
782 ;; Allowed chars for 4000 bit are Ss in position 3 | |
783 ;; Allowed chars for 2000 bit are Ssl in position 6 | |
784 ;; Allowed chars for 1000 bit are Tt in position 9 | |
785 (defun wdired-perms-to-number (perms) | |
74526
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
786 (let ((nperm 0777)) |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
787 (if (= (elt perms 1) ?-) (setq nperm (- nperm 400))) |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
788 (if (= (elt perms 2) ?-) (setq nperm (- nperm 200))) |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
789 (let ((p-bit (elt perms 3))) |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
790 (if (memq p-bit '(?- ?S)) (setq nperm (- nperm 100))) |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
791 (if (memq p-bit '(?s ?S)) (setq nperm (+ nperm 4000)))) |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
792 (if (= (elt perms 4) ?-) (setq nperm (- nperm 40))) |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
793 (if (= (elt perms 5) ?-) (setq nperm (- nperm 20))) |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
794 (let ((p-bit (elt perms 6))) |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
795 (if (memq p-bit '(?- ?S ?l)) (setq nperm (- nperm 10))) |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
796 (if (memq p-bit '(?s ?S ?l)) (setq nperm (+ nperm 2000)))) |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
797 (if (= (elt perms 7) ?-) (setq nperm (- nperm 4))) |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
798 (if (= (elt perms 8) ?-) (setq nperm (- nperm 2))) |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
799 (let ((p-bit (elt perms 9))) |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
800 (if (memq p-bit '(?- ?T)) (setq nperm (- nperm 1))) |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
801 (if (memq p-bit '(?t ?T)) (setq nperm (+ nperm 1000)))) |
1a43c99020cb
(wdired-change-to-wdired-mode, wdired-finish-edit)
Chong Yidong <cyd@stupidchicken.com>
parents:
72160
diff
changeset
|
802 nperm)) |
55098 | 803 |
804 ;; Perform the changes in the permissions of the files that have | |
805 ;; changed. | |
806 (defun wdired-do-perm-changes () | |
807 (let ((changes nil) | |
808 (errors 0) | |
809 (prop-wanted (if (eq wdired-allow-to-change-permissions 'advanced) | |
810 'old-perm 'perm-changed)) | |
811 filename perms-ori perms-new perm-tmp) | |
812 (goto-char (next-single-property-change (point-min) prop-wanted | |
813 nil (point-max))) | |
814 (while (not (eobp)) | |
815 (setq perms-ori (get-text-property (point) 'old-perm)) | |
816 (setq perms-new (buffer-substring-no-properties | |
817 (point) (next-single-property-change (point) 'end-perm))) | |
68680
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
818 (unless (equal perms-ori perms-new) |
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
819 (setq changes t) |
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
820 (setq filename (wdired-get-filename nil t)) |
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
821 (if (= (length perms-new) 10) |
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
822 (progn |
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
823 (setq perm-tmp |
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
824 (int-to-string (wdired-perms-to-number perms-new))) |
81639
8e5203081e80
* dired-aux.el: Remove `dired-call-process'.
Michael Albinus <michael.albinus@gmx.de>
parents:
75347
diff
changeset
|
825 (unless (equal 0 (process-file dired-chmod-program |
8e5203081e80
* dired-aux.el: Remove `dired-call-process'.
Michael Albinus <michael.albinus@gmx.de>
parents:
75347
diff
changeset
|
826 nil nil nil perm-tmp filename)) |
68680
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
827 (setq errors (1+ errors)) |
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
828 (dired-log (concat dired-chmod-program " " perm-tmp |
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
829 " `" filename "' failed\n\n")))) |
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
830 (setq errors (1+ errors)) |
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
831 (dired-log (concat "Cannot parse permission `" perms-new |
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
832 "' for file `" filename "'\n\n")))) |
55098 | 833 (goto-char (next-single-property-change (1+ (point)) prop-wanted |
834 nil (point-max)))) | |
835 (cons changes errors))) | |
836 | |
837 (provide 'wdired) | |
838 | |
68680
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
839 ;; Local Variables: |
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
840 ;; coding: latin-1 |
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
841 ;; byte-compile-dynamic: t |
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
842 ;; End: |
bdaa27dd39d3
(wdired-mode-map): Use remap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68671
diff
changeset
|
843 |
55098 | 844 ;;; wdired.el ends here |