changeset 108324:297d4e80151f

* files.el (copy-directory): Handle symlinks (Bug#5982).
author Chong Yidong <cyd@stupidchicken.com>
date Tue, 20 Apr 2010 18:28:26 -0400
parents bdf81babd7c5
children cac9af6437d5 aee37a797ab7 486e3cc1b3a6
files lisp/ChangeLog lisp/files.el
diffstat 2 files changed, 10 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Tue Apr 20 12:04:05 2010 -0400
+++ b/lisp/ChangeLog	Tue Apr 20 18:28:26 2010 -0400
@@ -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).
 
--- a/lisp/files.el	Tue Apr 20 12:04:05 2010 -0400
+++ b/lisp/files.el	Tue Apr 20 18:28:26 2010 -0400
@@ -4735,10 +4735,14 @@
       (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))