home *** CD-ROM | disk | FTP | other *** search
- ;From: rbj@DSYS.NCSL.NIST.GOV (Root Boy Jim)
- ;Newsgroups: gnu.emacs.bug
- ;Subject: Renaming Files With DIRED
- ;Message-ID: <8908311954.AA23564@dsys.ncsl.nist.gov>
- ;Date: 31 Aug 89 19:54:32 GMT
- ;Distribution: gnu
- ;Organization: National Institute of Standards and Technology formerly National Bureau of Standards
- ;Lines: 67
- ;
- ;? From: wpmstr!omaha1!fpb%sunpitt.East@sun.com (Frank P. Bresz - Westinghouse ITTC)
- ;
- ;? In GNU Emacs 18.52.3 of Tue Apr 11 1989 on omaha1 (berkeley-unix)
- ;
- ;? Hi,
- ;? I have just finished implementing a change to dired.el to allow you
- ;? to move a file from 1 directory to another easily. It seems that I often
- ;? want to do this and the functionality did not exist, so I added it. The
- ;? code I wrote may be a touch inelegant. If anyone wants the code I can
- ;? mail it.
- ;
- ;I have always wanted this too. Your note prompted me to code it up.
- ;I also added the ability to overwrite the file if desired.
-
- (defun dired-rename-file (to-file)
- "Rename this file to TO-FILE."
- (interactive "FRename to: ")
- ;;;; (interactive
- ;;;; (list (read-file-name (format "Rename %s to: "
- ;;;; (file-name-nondirectory (dired-get-filename)))
- ;;;; nil (dired-get-filename))))
- (setq to-file (expand-file-name to-file))
- (and (file-directory-p to-file)
- (setq to-file
- (concat (file-name-as-directory to-file)
- (file-name-nondirectory
- (dired-get-filename)))))
- (rename-file (dired-get-filename) to-file 0)
- (let ((buffer-read-only nil))
- (beginning-of-line)
- (delete-region (point) (progn (forward-line 1) (point)))
- (setq to-file (expand-file-name to-file))
- (dired-add-entry (file-name-directory to-file)
- (file-name-nondirectory to-file))))
-
- (defun dired-copy-file (to-file)
- "Copy this file to TO-FILE."
- (interactive "FCopy to: ")
- (setq to-file (expand-file-name to-file))
- (and (file-directory-p to-file)
- (setq to-file
- (concat (file-name-as-directory to-file)
- (file-name-nondirectory
- (dired-get-filename)))))
- (copy-file (dired-get-filename) to-file 0)
- ;;;; (setq to-file (expand-file-name to-file))
- (dired-add-entry (file-name-directory to-file)
- (file-name-nondirectory to-file)))
-
- ;BTW, I changed the interactive spec on dired-rename-file to match
- ;the one on dired-copy-file. Does anyone know why they differ?
- ;I also moved the expand-file-name in copy up a bit to match the
- ;one in dired-rename-file. Anyone know why they differ, or even
- ;why it is present?
- ;
- ;? Frank P. Bresz }*{
- ;? sunpitt!wpmstr!omaha1!fpb@Sun.COM
- ;
- ;? !!! PLEASE USE THE ABOVE ADDRESS
- ;? !!! DO NOT REPLY TO THE ADDRESS GENERATED BY THE MAILER:
- ;? !!! wpmstr!omaha1!fbresz%sunpitt.East@sun.com
- ;? !!! SUN.COM rejects it.
- ;
- ;'nother feechur from the dired wizard,
- ;
- ; Root Boy Jim and
- ; the GNU Bohemians
-