Function: speedbar-item-copy

speedbar-item-copy is an interactive and byte-compiled function defined in speedbar.el.gz.

Signature

(speedbar-item-copy)

Documentation

Copy the item under the cursor.

Files can be copied to new names or places.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/speedbar.el.gz
(defun speedbar-item-copy ()
  "Copy the item under the cursor.
Files can be copied to new names or places."
  (interactive)
  (let ((f (speedbar-line-file)))
    (if (not f)	(error "Not a file"))
    (if (file-directory-p f)
	(error "Cannot copy directory")
      (let* ((rt (read-file-name (format "Copy %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
	      (copy-file f rt t t)
	      ;; refresh display if the new place is currently displayed.
	      (if refresh
		  (progn
		    (speedbar-refresh)
		    (if (not (speedbar-goto-this-file rt))
			(speedbar-goto-this-file f))))
	      ))))))