diff options
| author | thierry volpiatto | 2012-02-28 10:28:52 +0100 |
|---|---|---|
| committer | thierry volpiatto | 2012-02-28 10:28:52 +0100 |
| commit | 96b49301274ac12ce82c3dfd3361929f0344b9e3 (patch) | |
| tree | 0f02fd46c34e33112a1bfbec852c8c4e7417910a | |
| parent | 44e97401cda5b464505ac798ae7f71dce0d2a06e (diff) | |
| download | emacs-96b49301274ac12ce82c3dfd3361929f0344b9e3.tar.gz emacs-96b49301274ac12ce82c3dfd3361929f0344b9e3.zip | |
* lisp/files.el (file-equal-p): renamed from `files-equal-p'.
Now return nil when one or both files doesn't exists.
(file-subdir-of-p): Now only top directory must exists,
return nil if it doesn't.
(copy-directory): No need to test with `file-subdir-of-p' after creating dir.
* tramp.el (tramp-file-name-for-operation): Rename `files-equal-p' to `file-equal-p'.
* files.texi: Rename `files-equal-p' to `file-equal-p'.
| -rw-r--r-- | doc/lispref/ChangeLog | 5 | ||||
| -rw-r--r-- | doc/lispref/files.texi | 9 | ||||
| -rw-r--r-- | lisp/ChangeLog | 9 | ||||
| -rw-r--r-- | lisp/files.el | 32 | ||||
| -rw-r--r-- | lisp/net/tramp.el | 2 |
5 files changed, 32 insertions, 25 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog index b27bcef9c12..1b5418b47aa 100644 --- a/doc/lispref/ChangeLog +++ b/doc/lispref/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2012-02-28 Thierry Volpiatto <thierry.volpiatto@gmail.com> | ||
| 2 | |||
| 3 | * files.texi Rename files-equal-p to file-equal-p. | ||
| 4 | Update chnaged behavior of file-subdir-of-p. | ||
| 5 | |||
| 1 | 2012-02-28 Glenn Morris <rgm@gnu.org> | 6 | 2012-02-28 Glenn Morris <rgm@gnu.org> |
| 2 | 7 | ||
| 3 | * advice.texi, anti.texi, display.texi, elisp.texi: | 8 | * advice.texi, anti.texi, display.texi, elisp.texi: |
diff --git a/doc/lispref/files.texi b/doc/lispref/files.texi index cffaef37988..87a3035403f 100644 --- a/doc/lispref/files.texi +++ b/doc/lispref/files.texi | |||
| @@ -1018,7 +1018,7 @@ a regular file (not a directory, named pipe, terminal, or | |||
| 1018 | other I/O device). | 1018 | other I/O device). |
| 1019 | @end defun | 1019 | @end defun |
| 1020 | 1020 | ||
| 1021 | @defun files-equal-p file1 file2 | 1021 | @defun file-equal-p file1 file2 |
| 1022 | This function returns @code{t} if the files @var{file1} and | 1022 | This function returns @code{t} if the files @var{file1} and |
| 1023 | @var{file2} name the same file. Two ordinary files are considered to | 1023 | @var{file2} name the same file. Two ordinary files are considered to |
| 1024 | be the same if the function @code{file-attributes} (@pxref{File | 1024 | be the same if the function @code{file-attributes} (@pxref{File |
| @@ -1029,9 +1029,8 @@ Attributes}) returns @code{equal} values for them. | |||
| 1029 | This function returns @code{t} if directory @var{dir1} is a | 1029 | This function returns @code{t} if directory @var{dir1} is a |
| 1030 | subdirectory of @var{dir2}, or if @var{dir1} and @var{dir2} are the | 1030 | subdirectory of @var{dir2}, or if @var{dir1} and @var{dir2} are the |
| 1031 | same directory. It compares the @code{file-truename} values of the | 1031 | same directory. It compares the @code{file-truename} values of the |
| 1032 | two directories (@pxref{Truenames}). If either @var{dir1} or | 1032 | two directories (@pxref{Truenames}). If @var{dir2} |
| 1033 | @var{dir2} do not name existing directories, the return value is | 1033 | do not name an existing directory, the return value is @code{nil}. |
| 1034 | @code{nil}. | ||
| 1035 | @end defun | 1034 | @end defun |
| 1036 | 1035 | ||
| 1037 | @node Truenames | 1036 | @node Truenames |
| @@ -2722,7 +2721,7 @@ first, before handlers for jobs such as remote file access. | |||
| 2722 | @code{file-ownership-preserved-p}, | 2721 | @code{file-ownership-preserved-p}, |
| 2723 | @code{file-readable-p}, @code{file-regular-p}, @code{file-subdir-of-p}, | 2722 | @code{file-readable-p}, @code{file-regular-p}, @code{file-subdir-of-p}, |
| 2724 | @code{file-symlink-p}, @code{file-truename}, @code{file-writable-p}, | 2723 | @code{file-symlink-p}, @code{file-truename}, @code{file-writable-p}, |
| 2725 | @code{files-equal-p}, @code{find-backup-file-name}, | 2724 | @code{file-equal-p}, @code{find-backup-file-name}, |
| 2726 | @c Not sure why it was here: @code{find-file-noselect},@* | 2725 | @c Not sure why it was here: @code{find-file-noselect},@* |
| 2727 | @code{get-file-buffer}, | 2726 | @code{get-file-buffer}, |
| 2728 | @code{insert-directory}, | 2727 | @code{insert-directory}, |
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index ab70527073a..b92ef3d6b12 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,12 @@ | |||
| 1 | 2012-02-28 Thierry Volpiatto <thierry.volpiatto@gmail.com> | ||
| 2 | |||
| 3 | * lisp/files.el (file-equal-p): renamed from `files-equal-p'. | ||
| 4 | Now return nil when one or both files doesn't exists. | ||
| 5 | (file-subdir-of-p): Now only top directory must exists, | ||
| 6 | return nil if it doesn't. | ||
| 7 | (copy-directory): No need to test with `file-subdir-of-p' after creating dir. | ||
| 8 | * tramp.el (tramp-file-name-for-operation): Rename `files-equal-p' to `file-equal-p'. | ||
| 9 | |||
| 1 | 2012-02-28 Glenn Morris <rgm@gnu.org> | 10 | 2012-02-28 Glenn Morris <rgm@gnu.org> |
| 2 | 11 | ||
| 3 | * shell.el (shell-mode): | 12 | * shell.el (shell-mode): |
diff --git a/lisp/files.el b/lisp/files.el index 8ebb98c001b..0d687a157fe 100644 --- a/lisp/files.el +++ b/lisp/files.el | |||
| @@ -4985,27 +4985,26 @@ given. With a prefix argument, TRASH is nil." | |||
| 4985 | directory 'full directory-files-no-dot-files-regexp))) | 4985 | directory 'full directory-files-no-dot-files-regexp))) |
| 4986 | (delete-directory-internal directory))))) | 4986 | (delete-directory-internal directory))))) |
| 4987 | 4987 | ||
| 4988 | (defun files-equal-p (file1 file2) | 4988 | (defun file-equal-p (file1 file2) |
| 4989 | "Return non-nil if FILE1 and FILE2 name the same file. | 4989 | "Return non-nil if existing files FILE1 and FILE2 name the same file. |
| 4990 | Ordinary files are considered to be the same if `file-attributes' | 4990 | Return nil if one or both files doesn't exists." |
| 4991 | returns `equal' values for them." | 4991 | (let ((handler (or (find-file-name-handler file1 'file-equal-p) |
| 4992 | (let ((handler (or (find-file-name-handler file1 'files-equal-p) | 4992 | (find-file-name-handler file2 'file-equal-p)))) |
| 4993 | (find-file-name-handler file2 'files-equal-p)))) | ||
| 4994 | (if handler | 4993 | (if handler |
| 4995 | (funcall handler 'files-equal-p file1 file2) | 4994 | (funcall handler 'file-equal-p file1 file2) |
| 4996 | (equal (file-attributes (file-truename file1)) | 4995 | (let ((f1-attr (file-attributes (file-truename file1))) |
| 4997 | (file-attributes (file-truename file2)))))) | 4996 | (f2-attr (file-attributes (file-truename file2)))) |
| 4997 | (and f1-attr f2-attr (equal f1-attr f2-attr)))))) | ||
| 4998 | 4998 | ||
| 4999 | (defun file-subdir-of-p (dir1 dir2) | 4999 | (defun file-subdir-of-p (dir1 dir2) |
| 5000 | "Return non-nil if DIR1 is a subdirectory of DIR2. | 5000 | "Return non-nil if DIR1 is a subdirectory of DIR2. |
| 5001 | A directory is considered to be a subdirectory of itself. | 5001 | A directory is considered to be a subdirectory of itself. |
| 5002 | Return nil if DIR1 or DIR2 are not existing directories." | 5002 | Return nil if top directory DIR2 is not an existing directory." |
| 5003 | (let ((handler (or (find-file-name-handler dir1 'file-subdir-of-p) | 5003 | (let ((handler (or (find-file-name-handler dir1 'file-subdir-of-p) |
| 5004 | (find-file-name-handler dir2 'file-subdir-of-p)))) | 5004 | (find-file-name-handler dir2 'file-subdir-of-p)))) |
| 5005 | (if handler | 5005 | (if handler |
| 5006 | (funcall handler 'file-subdir-of-p dir1 dir2) | 5006 | (funcall handler 'file-subdir-of-p dir1 dir2) |
| 5007 | (when (and (file-directory-p dir1) | 5007 | (when (file-directory-p dir2) ; Top dir must exist. |
| 5008 | (file-directory-p dir2)) | ||
| 5009 | (setq dir1 (file-truename dir1) | 5008 | (setq dir1 (file-truename dir1) |
| 5010 | dir2 (file-truename dir2)) | 5009 | dir2 (file-truename dir2)) |
| 5011 | (let ((ls1 (or (split-string dir1 "/" t) '("/"))) | 5010 | (let ((ls1 (or (split-string dir1 "/" t) '("/"))) |
| @@ -5019,7 +5018,7 @@ Return nil if DIR1 or DIR2 are not existing directories." | |||
| 5019 | (setq ls1 (cdr ls1) | 5018 | (setq ls1 (cdr ls1) |
| 5020 | ls2 (cdr ls2))) | 5019 | ls2 (cdr ls2))) |
| 5021 | (unless mismatch | 5020 | (unless mismatch |
| 5022 | (files-equal-p (file-truename root) dir2))))))) | 5021 | (file-equal-p root dir2))))))) |
| 5023 | 5022 | ||
| 5024 | (defun copy-directory (directory newname &optional keep-time parents copy-contents) | 5023 | (defun copy-directory (directory newname &optional keep-time parents copy-contents) |
| 5025 | "Copy DIRECTORY to NEWNAME. Both args must be strings. | 5024 | "Copy DIRECTORY to NEWNAME. Both args must be strings. |
| @@ -5065,12 +5064,7 @@ directly into NEWNAME instead." | |||
| 5065 | (cond ((not (file-directory-p newname)) | 5064 | (cond ((not (file-directory-p newname)) |
| 5066 | ;; If NEWNAME is not an existing directory, create it; | 5065 | ;; If NEWNAME is not an existing directory, create it; |
| 5067 | ;; that is where we will copy the files of DIRECTORY. | 5066 | ;; that is where we will copy the files of DIRECTORY. |
| 5068 | (make-directory newname parents) | 5067 | (make-directory newname parents)) |
| 5069 | ;; `file-subdir-of-p' doesn't handle non--existing directories, | ||
| 5070 | ;; so double check now if NEWNAME is not a subdir of DIRECTORY. | ||
| 5071 | (and (file-subdir-of-p newname directory) | ||
| 5072 | (error "Cannot copy `%s' into its subdirectory `%s'" | ||
| 5073 | directory newname))) | ||
| 5074 | ;; If NEWNAME is an existing directory and COPY-CONTENTS | 5068 | ;; If NEWNAME is an existing directory and COPY-CONTENTS |
| 5075 | ;; is nil, copy into NEWNAME/[DIRECTORY-BASENAME]. | 5069 | ;; is nil, copy into NEWNAME/[DIRECTORY-BASENAME]. |
| 5076 | ((not copy-contents) | 5070 | ((not copy-contents) |
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index a5e3da9d04c..df0ac53a8f8 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el | |||
| @@ -1810,7 +1810,7 @@ ARGS are the arguments OPERATION has been called with." | |||
| 1810 | ;; Emacs 23+ only. | 1810 | ;; Emacs 23+ only. |
| 1811 | 'copy-directory | 1811 | 'copy-directory |
| 1812 | ;; Emacs 24+ only. | 1812 | ;; Emacs 24+ only. |
| 1813 | 'files-equal-p 'file-subdir-of-p | 1813 | 'file-equal-p 'file-subdir-of-p |
| 1814 | ;; XEmacs only. | 1814 | ;; XEmacs only. |
| 1815 | 'dired-make-relative-symlink | 1815 | 'dired-make-relative-symlink |
| 1816 | 'vm-imap-move-mail 'vm-pop-move-mail 'vm-spool-move-mail)) | 1816 | 'vm-imap-move-mail 'vm-pop-move-mail 'vm-spool-move-mail)) |