]> code.delx.au - gnu-emacs/blobdiff - lisp/files.el
(tab-always-indent): Fix custom-type.
[gnu-emacs] / lisp / files.el
index b848407b3ae8625fbdcc8aa9000a81a51d1e9361..99e818643d0a2cc9463453b7c891e0c74ab831ea 100644 (file)
@@ -2,7 +2,7 @@
 
 ;; Copyright (C) 1985, 1986, 1987, 1992, 1993, 1994, 1995, 1996,
 ;;   1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
-;;   2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+;;   2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
 
@@ -1284,9 +1284,13 @@ its documentation for additional customization information."
     ))
 
 (defmacro minibuffer-with-setup-hook (fun &rest body)
-  "Add FUN to `minibuffer-setup-hook' while executing BODY.
+  "Temporarily add FUN to `minibuffer-setup-hook' while executing BODY.
 BODY should use the minibuffer at most once.
-Recursive uses of the minibuffer will not be affected."
+Recursive uses of the minibuffer are unaffected (FUN is not
+called additional times).
+
+This macro actually adds an auxiliary function that calls FUN,
+rather than FUN itself, to `minibuffer-setup-hook'."
   (declare (indent 1) (debug t))
   (let ((hook (make-symbol "setup-hook")))
     `(let (,hook)
@@ -4710,20 +4714,17 @@ this happens by default."
       ;; Compute target name.
       (setq directory (directory-file-name (expand-file-name directory))
            newname   (directory-file-name (expand-file-name newname)))
-      (if (and (file-directory-p newname)
-              (not (string-equal (file-name-nondirectory directory)
-                                 (file-name-nondirectory newname))))
-         (setq newname
-               (expand-file-name (file-name-nondirectory directory) newname)))
       (if (not (file-directory-p newname)) (make-directory newname parents))
 
       ;; Copy recursively.
       (mapc
        (lambda (file)
-        (if (file-directory-p file)
-            (copy-directory file newname keep-time parents)
-          (copy-file file newname t keep-time)))
-       ;; We do not want to delete "." and "..".
+        (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))))
+       ;; We do not want to copy "." and "..".
        (directory-files        directory 'full directory-files-no-dot-files-regexp))
 
       ;; Set directory attributes.
@@ -5365,7 +5366,10 @@ default directory.  However, if FULL is non-nil, they are absolute."
           ;; A list of all dirs that DIRPART specifies.
           ;; This can be more than one dir
           ;; if DIRPART contains wildcards.
-          (dirs (if (and dirpart (string-match "[[*?]" dirpart))
+          (dirs (if (and dirpart
+                         (string-match "[[*?]"
+                                       (or (file-remote-p dirpart 'localname)
+                                           dirpart)))
                     (mapcar 'file-name-as-directory
                             (file-expand-wildcards (directory-file-name dirpart)))
                   (list dirpart)))
@@ -5392,6 +5396,9 @@ default directory.  However, if FULL is non-nil, they are absolute."
        (setq dirs (cdr dirs)))
       contents)))
 
+;; Let Tramp know that `file-expand-wildcards' does not need an advice.
+(provide 'files '(remote-wildcards))
+
 (defun list-directory (dirname &optional verbose)
   "Display a list of files in or matching DIRNAME, a la `ls'.
 DIRNAME is globbed by the shell if necessary.