aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/lispref/ChangeLog5
-rw-r--r--doc/lispref/files.texi21
-rw-r--r--doc/lispref/modes.texi2
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/files.el35
5 files changed, 41 insertions, 28 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog
index a339205a7fe..6d9cd6b4f8a 100644
--- a/doc/lispref/ChangeLog
+++ b/doc/lispref/ChangeLog
@@ -1,3 +1,8 @@
12012-02-26 Chong Yidong <cyd@gnu.org>
2
3 * files.texi (Kinds of Files): Improve documentation of
4 files-equal-p and file-subdir-of-p.
5
12012-02-26 Glenn Morris <rgm@gnu.org> 62012-02-26 Glenn Morris <rgm@gnu.org>
2 7
3 * intro.texi (Acknowledgements): Small changes. 8 * intro.texi (Acknowledgements): Small changes.
diff --git a/doc/lispref/files.texi b/doc/lispref/files.texi
index 1fee572a573..277a4cabdf1 100644
--- a/doc/lispref/files.texi
+++ b/doc/lispref/files.texi
@@ -1019,20 +1019,19 @@ other I/O device).
1019@end defun 1019@end defun
1020 1020
1021@defun files-equal-p file1 file2 1021@defun files-equal-p file1 file2
1022This function return @code{t} if the files @var{file1} and @var{file2} name 1022This function returns @code{t} if the files @var{file1} and
1023the same file. 1023@var{file2} name the same file. Two ordinary files are considered to
1024Comparison is made with the @code{file-attributes} of both files. 1024be the same if the function @code{file-attributes} (@xref{File
1025Attributes}) returns @code{equal} values for them.
1025@end defun 1026@end defun
1026 1027
1027@defun file-subdir-of-p dir1 dir2 1028@defun file-subdir-of-p dir1 dir2
1028This function return @code{t} if directory @var{dir1} is a subdirectory 1029This function returns @code{t} if directory @var{dir1} is a
1029of @var{dir2} or if @var{dir1} and @var{dir2} are the same directory. 1030subdirectory of @var{dir2}, or if @var{dir1} and @var{dir2} are the
1030Arguments @var{dir1} and @var{dir2} must be existing directories, 1031same directory. It compares the @code{file-truename} values of the
1031otherwise, return nil. 1032two directories (@pxref{Truenames}). If either @var{dir1} or
1032Check is done by building a directory name based on equality of differents 1033@var{dir2} do not name existing directories, the return value is
1033components of both directory names, if this resulting directory name 1034@code{nil}.
1034is equal to @var{dir2}, we assume directory @var{dir1}
1035is a subdirectory of @var{dir2}.
1036@end defun 1035@end defun
1037 1036
1038@node Truenames 1037@node Truenames
diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi
index a4ee6f8327f..eac895b6279 100644
--- a/doc/lispref/modes.texi
+++ b/doc/lispref/modes.texi
@@ -1596,7 +1596,7 @@ where @var{get} is an expression that returns the current state,
1596and @var{set} is a function of one argument (a state) that sets it. 1596and @var{set} is a function of one argument (a state) that sets it.
1597 1597
1598@item :after-hook @var{after-hook} 1598@item :after-hook @var{after-hook}
1599This defines a single lisp form which is evaluated after the mode hooks 1599This defines a single Lisp form which is evaluated after the mode hooks
1600have run. It should not be quoted. 1600have run. It should not be quoted.
1601@end table 1601@end table
1602 1602
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index f585be4ec34..418be2539b6 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
12012-02-26 Chong Yidong <cyd@gnu.org>
2
3 * files.el (files-equal-p): Doc fix.
4 (file-subdir-of-p): Doc fix. Convert loop macro to plain Lisp,
5 and quit the loop once a mismatch is found.
6
12012-02-25 Juanma Barranquero <lekktu@gmail.com> 72012-02-25 Juanma Barranquero <lekktu@gmail.com>
2 8
3 * bs.el (bs--show-with-configuration): Don't throw an error 9 * bs.el (bs--show-with-configuration): Don't throw an error
diff --git a/lisp/files.el b/lisp/files.el
index 3523fbdc012..acd04de34ec 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -4986,7 +4986,9 @@ given. With a prefix argument, TRASH is nil."
4986 (delete-directory-internal directory))))) 4986 (delete-directory-internal directory)))))
4987 4987
4988(defun files-equal-p (file1 file2) 4988(defun files-equal-p (file1 file2)
4989 "Return non-nil if FILE1 and FILE2 name the same file." 4989 "Return non-nil if FILE1 and FILE2 name the same file.
4990Ordinary files are considered to be the same if `file-attributes'
4991returns `equal' values for them."
4990 (let ((handler (or (find-file-name-handler file1 'files-equal-p) 4992 (let ((handler (or (find-file-name-handler file1 'files-equal-p)
4991 (find-file-name-handler file2 'files-equal-p)))) 4993 (find-file-name-handler file2 'files-equal-p))))
4992 (if handler 4994 (if handler
@@ -4996,27 +4998,28 @@ given. With a prefix argument, TRASH is nil."
4996 4998
4997(defun file-subdir-of-p (dir1 dir2) 4999(defun file-subdir-of-p (dir1 dir2)
4998 "Return non-nil if DIR1 is a subdirectory of DIR2. 5000 "Return non-nil if DIR1 is a subdirectory of DIR2.
4999Note that a directory is treated by this function as a subdirectory of itself. 5001A directory is considered to be a subdirectory of itself.
5000This function only works when its two arguments already exist, 5002Return nil if DIR1 or DIR2 are not existing directories."
5001when they don't, it returns nil."
5002 (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)
5003 (find-file-name-handler dir2 'file-subdir-of-p)))) 5004 (find-file-name-handler dir2 'file-subdir-of-p))))
5004 (if handler 5005 (if handler
5005 (funcall handler 'file-subdir-of-p dir1 dir2) 5006 (funcall handler 'file-subdir-of-p dir1 dir2)
5006 (when (and (file-directory-p dir1) 5007 (when (and (file-directory-p dir1)
5007 (file-directory-p dir2)) 5008 (file-directory-p dir2))
5008 (loop with f1 = (file-truename dir1) 5009 (setq dir1 (file-truename dir1)
5009 with f2 = (file-truename dir2) 5010 dir2 (file-truename dir2))
5010 with ls1 = (or (split-string f1 "/" t) (list "/")) 5011 (let ((ls1 (or (split-string dir1 "/" t) '("/")))
5011 with ls2 = (or (split-string f2 "/" t) (list "/")) 5012 (ls2 (or (split-string dir2 "/" t) '("/")))
5012 for p = (string-match "^/" f1) 5013 (root (if (string-match "\\`/" dir1) "/" ""))
5013 for i in ls1 5014 (mismatch nil))
5014 for j in ls2 5015 (while (and ls1 ls2 (not mismatch))
5015 when (string= i j) 5016 (if (string-equal (car ls1) (car ls2))
5016 concat (if p (concat "/" i) (concat i "/")) 5017 (setq root (concat root (car ls1) "/"))
5017 into root 5018 (setq mismatch t))
5018 finally return 5019 (setq ls1 (cdr ls1)
5019 (files-equal-p (file-truename root) f2)))))) 5020 ls2 (cdr ls2)))
5021 (unless mismatch
5022 (files-equal-p (file-truename root) dir2)))))))
5020 5023
5021(defun copy-directory (directory newname &optional keep-time parents copy-contents) 5024(defun copy-directory (directory newname &optional keep-time parents copy-contents)
5022 "Copy DIRECTORY to NEWNAME. Both args must be strings. 5025 "Copy DIRECTORY to NEWNAME. Both args must be strings.