Article View: gnu.emacs.bug
Article #99100Re: Dired: mv, mkdir
From: LUSYSNZ
Date: Fri, 26 Oct 1990 21:37
Date: Fri, 26 Oct 1990 21:37
111 lines
4999 bytes
4999 bytes
Relay-Version: VMS News - V5.9C 19/12/89 VAX/VMS V5.3; site vax1.cc.lehigh.edu
Path: vax1.cc.lehigh.edu!vax1.cc.lehigh.edu!netnews.upenn.edu!rutgers!tut.cis.ohio-state.edu!COMP.VUW.AC.NZ!Mike.Williams
Newsgroups: gnu.emacs.bug
Subject: Re: Dired: mv, mkdir
Message-ID: <BYRD.90Oct19122535@downstage.comp.vuw.ac.nz>
From: Mike.Williams@COMP.VUW.AC.NZ (Mike Williams)
Date: 19 Oct 90 16:25:35 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: Dept. of Computer Science, Victoria Uni. of Wellington, NZ.
Approved: bug-gnu-emacs@prep.ai.mit.edu
Lines: 98
+-- In article <9010151328.AA02444@.diderot.gr.osf.org.>
macrakis@DIDEROT.GR.OSF.ORG (Stavros Macrakis) writes:
|
| I suggest that Dired allow renaming/moving (r) and copying (c) a file
| to a directory as well as to a file.
|
| It would also be nice to be able to create directories within Dired.
The code included below should do what you want. I've also included a
rewrite of dired-add-entry, as the old version seemed to do strange
things with symlinks.
--- cut here ---
;; Copyright Mike Williams 1990 etc etc
;; No warranty, you can copy it, blah blah
(defun dired-rename-file (to-file)
"Rename this file to TO-FILE."
(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))
(if (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)
(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))
(if (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)
(setq to-file (expand-file-name to-file))
(dired-add-entry (file-name-directory to-file)
(file-name-nondirectory to-file)))
(defun dired-mkdir (dir)
"Create a new sub-directory."
(interactive "FNew directory name: ")
(call-process "mkdir" nil nil nil (expand-file-name dir))
(message "Directory %s created." dir)
(dired-add-entry default-directory
(file-name-nondirectory dir)))
(defun dired-symlink (to link)
"Make a symbolic link to another file."
(interactive "fSymbolic link to: \nFLink name: ")
(setq link (expand-file-name link))
(call-process "ln" nil nil nil "-s"
(expand-file-name to) link)
(message "Symbolic link created.")
(dired-add-entry (file-name-directory link)
(file-name-nondirectory link)))
;;=== dired-add-entry ===
;; The old version did funny things with symlinks. In any case, I can't
;; see why it has to delete the filename then re-insert it !!
(defun dired-add-entry (directory filename)
;; If tree dired is implemented, this function will have to do
;; something smarter with the directory. Currently, just check
;; default directory, if same, add the new entry at point. With tree
;; dired, should call 'dired-current-directory' or similar. Note
;; that this adds the entry 'out of order' if files sorted by time,
;; etc.
(if (string-equal directory default-directory)
(let ((buffer-read-only nil))
(beginning-of-line)
(call-process "ls" nil t nil "-d" dired-listing-switches
filename)
;; (concat directory filename)
(forward-line -1)
(insert " ")
;; (dired-move-to-filename)
;; (let* ((beg (point))
;; (end (progn (end-of-line) (point))))
;; (setq filename (buffer-substring beg end))
;; (delete-region beg end)
;; (insert (file-name-nondirectory filename)))
(beginning-of-line))))
--- end of code ---
--
/-------------------- byrd@comp.vuw.ac.nz --------------------\
| Mike Williams, Victoria University of Wellington, Aotearoa. |
\-------- Yesterday, I ... no, wait, that wasn't me. ---------/
Technical Details
Message-ID:
<138E63DF865F800042@VAX1.CC.LEHIGH.EDU>Path:
arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!shelby!agate!ucbvax!tut.cis.ohio-state.edu!VAX1.CC.LEHIGH.EDU!LUSYSNZShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fb2f1,e9494d74a6b4f39b,start X-Google-Attributes: gidfb2f1,public X-Google-ArrivalTime: 1990-10-26 14:37:00 PST Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!shelby!agate!ucbvax!tut.cis.ohio-state.edu!VAX1.CC.LEHIGH.EDU!LUSYSNZ From: LUSYSNZ@VAX1.CC.LEHIGH.EDU Newsgroups: gnu.emacs.bug Subject: Re: Dired: mv, mkdir Message-ID: <138E63DF865F800042@VAX1.CC.LEHIGH.EDU> Date: 26 Oct 90 21:37:00 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: Gnus Not Usenet Lines: 111 Approved: bug-gnu-emacs@prep.ai.mit.edu Posted: Fri Oct 26 22:37:00 1990