Function: wdired-change-to-wdired-mode

wdired-change-to-wdired-mode is an autoloaded, interactive and byte-compiled function defined in wdired.el.gz.

Signature

(wdired-change-to-wdired-mode)

Documentation

Put a Dired buffer in Writable Dired (WDired) mode.

In WDired mode, you can edit the names of the files in the buffer, the target of the links, and the permission bits of the files. After typing C-c C-c (wdired-finish-edit), Emacs modifies the files and directories to reflect your edits.

See wdired-mode.

View in manual

Probably introduced at or before Emacs version 23.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/wdired.el.gz
;;;###autoload
(defun wdired-change-to-wdired-mode ()
  "Put a Dired buffer in Writable Dired (WDired) mode.
\\<wdired-mode-map>
In WDired mode, you can edit the names of the files in the
buffer, the target of the links, and the permission bits of the
files.  After typing \\[wdired-finish-edit], Emacs modifies the files and
directories to reflect your edits.

See `wdired-mode'."
  (interactive)
  (unless (derived-mode-p 'dired-mode)
    (error "Not a Dired buffer"))
  (setq-local wdired--old-content
              (buffer-substring (point-min) (point-max)))
  (setq-local wdired--old-marks
              (dired-remember-marks (point-min) (point-max)))
  (setq-local wdired--old-point (point))
  (wdired--set-permission-bounds)
  (when wdired-search-replace-filenames
    (add-function :around (local 'isearch-search-fun-function)
                  #'dired-isearch-search-filenames
                  '((isearch-message-prefix . "filename ")))
    (setq-local replace-search-function
                (setq-local replace-re-search-function
                            (funcall isearch-search-fun-function)))
    ;; Original dired hook removes dired-isearch-search-filenames that
    ;; is needed outside isearch for lazy-highlighting in query-replace.
    (remove-hook 'isearch-mode-hook #'dired-isearch-filenames-setup t))
  (use-local-map wdired-mode-map)
  (force-mode-line-update)
  (setq buffer-read-only nil)
  (dired-unadvertise default-directory)
  (add-hook 'kill-buffer-hook #'wdired-check-kill-buffer nil t)
  (add-hook 'before-change-functions #'wdired--before-change-fn nil t)
  (add-hook 'after-change-functions #'wdired--restore-properties nil t)
  (setq major-mode 'wdired-mode)
  (setq mode-name "Editable Dired")
  (add-function :override (local 'revert-buffer-function) #'wdired-revert)
  (set-buffer-modified-p nil)
  (setq buffer-undo-list nil)
  ;; Non-nil `dired-filename-display-length' may cause filenames to be
  ;; hidden partly, so we remove filename invisibility spec
  ;; temporarily to ensure filenames are visible for editing.
  (dired-filename-update-invisibility-spec)
  (run-mode-hooks 'wdired-mode-hook)
  (message "%s" (substitute-command-keys
		 "Press \\[wdired-finish-edit] when finished \
or \\[wdired-abort-changes] to abort changes")))