Function: speedbar-item-rename
speedbar-item-rename is an interactive and byte-compiled function
defined in speedbar.el.gz.
Signature
(speedbar-item-rename)
Documentation
Rename the item under the cursor or the mouse pointer.
Files can be renamed to new names or moved to new directories.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/speedbar.el.gz
(defun speedbar-item-rename ()
"Rename the item under the cursor or the mouse pointer.
Files can be renamed to new names or moved to new directories."
(interactive)
(let ((f (speedbar-line-file)))
(if f
(let* ((rt (read-file-name (format "Rename %s to: "
(file-name-nondirectory f))
(file-name-directory f)))
(refresh (member (expand-file-name (file-name-directory rt))
speedbar-shown-directories)))
;; Create the right file name part
(if (file-directory-p rt)
(setq rt
(concat (expand-file-name rt)
(if (string-match "[/\\]\\'" rt) "" "/")
(file-name-nondirectory f))))
(if (or (not (file-exists-p rt))
(speedbar-y-or-n-p (format "Overwrite %s with %s? " rt f)
t))
(progn
(rename-file f rt t)
;; refresh display if the new place is currently displayed.
(if refresh
(progn
(speedbar-refresh)
(speedbar-goto-this-file rt)
)))))
(error "Not a file"))))