From: "Xah Lee" <xah@xahlee.org>
To: <bug-gnu-emacs@gnu.org>
Subject: bug#4408: 23.1; suggestion: a elisp function for copying and deleting whole dir
Date: Fri, 11 Sep 2009 13:05:28 -0700 [thread overview]
Message-ID: <8439E9C1352F4A93BB772F169C434480@xahPC> (raw)
it appears to me, this is a good suggestion.
there lacks a function to copy and delete directories recursively.
in the elisp manual, the closest is:
(info "(elisp) Create/Delete Dirs")
it would be good to have a function that copy a whole dir, and another for
deleting whole dir.
Emacs does implement them in dired, or in eshell, apparently, but it's not
easy to use them.
many scripting langs provide such functions, and is very convenient.
for deleting dir, perhaps this can be implemented:
(delete-directory dirname &optional recursive)
for copying dir, perhaps it can be modeled on copy-file:
-- Command: copy-file oldname newname &optional ok-if-exists time
these should be perhaps few hours to implement for elisp developers, perhaps
by just pulling existing implementation from dired or eshell.
Once implemented, they'd be standard functions in elisp manual. They would
be great convience for average elisp coders.
As a personal example, i needed to both copy dir recursively and also delete
whole dir, in my use of elisp as a text processing lang. So far i've been
just calling shell. e.g.
(shell-command (concat "cp -R " fromDir " " toDir))
(shell-command (concat "find " destDir " -type d -name \"xx*\" -exec rm -R
{} \\;"))
my script worked well in the past 2 years, but replying on unix shell has
many complications. For example, recently i need my script to work on
Windows. With Windows, there's many complications, e.g. which unix shell you
use cygwin, msys, their config, their path env var config in emacs, both are
inter-related to which emacs distribution one is using (e.g. what shell runs
when you do M-x shell). Then, recently in one emacs distro i'm trying out
eshell (in hope that it perhaps more cross-platform than M-x shell or
Lennart emacsW23's shell, cmd-shell, msys-shell), but discovered that eshell
chocks on this standard bash syntax
find -name "*el" -exec rm {} \;
(reported in bug #4406. Doesn't work when called as shell-command neither)
In short, something trivial turns out to be 5 or more hours to trying to get
it work.
emacs + elisp is a great text processing lang, and one big advantage is that
it is cross platform. So, all things considered, i think the suggestion in
this report is a very good one, in particular its ratio of
impact/ease-to-implement is relatively high.
if i eventually got a solution from looking into dired or eshell for
copying/deleting dir, i'll update this report with code for draft
implementation.
Thanks.
Xah
∑ http://xahlee.org/
☄
reply other threads:[~2009-09-11 20:05 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8439E9C1352F4A93BB772F169C434480@xahPC \
--to=xah@xahlee.org \
--cc=4408@emacsbugs.donarmstrong.com \
--cc=bug-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).