summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChong Yidong <cyd@stupidchicken.com>2010-04-20 18:28:26 -0400
committerChong Yidong <cyd@stupidchicken.com>2010-04-20 18:28:26 -0400
commit99833607e0b6a5a49159ecedfa8ad40eb1671f6c (patch)
tree35b20da1b0de89391f426c6d00cbf865e6a55c08
parent790c2e44de7d6fcddceab31f1d18b1beb00267f3 (diff)
downloademacs-99833607e0b6a5a49159ecedfa8ad40eb1671f6c.tar.gz
* files.el (copy-directory): Handle symlinks (Bug#5982).
-rw-r--r--lisp/ChangeLog2
-rw-r--r--lisp/files.el12
2 files changed, 10 insertions, 4 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 6cf40c75d6c..8a8f7ef9732 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,7 @@
2010-04-20 Chong Yidong <cyd@stupidchicken.com>
+ * files.el (copy-directory): Handle symlinks (Bug#5982).
+
* progmodes/compile.el (compilation-next-error-function): Revert
2009-10-12 change (Bug#5983).
diff --git a/lisp/files.el b/lisp/files.el
index 99fa7ddf1b5..76345034c6e 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -4735,10 +4735,14 @@ this happens by default."
(mapc
(lambda (file)
(let ((target (expand-file-name
- (file-name-nondirectory file) newname)))
- (if (file-directory-p file)
- (copy-directory file target keep-time parents)
- (copy-file file target t keep-time))))
+ (file-name-nondirectory file) newname))
+ (attrs (file-attributes file)))
+ (cond ((file-directory-p file)
+ (copy-directory file target keep-time parents))
+ ((stringp (car attrs)) ; Symbolic link
+ (make-symbolic-link (car attrs) target t))
+ (t
+ (copy-file file target t keep-time)))))
;; We do not want to copy "." and "..".
(directory-files directory 'full directory-files-no-dot-files-regexp))