aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2014-03-25 18:08:45 +0200
committerEli Zaretskii2014-03-25 18:08:45 +0200
commit75b7e407e8d4303930dbfad2df2f36b994f368ed (patch)
tree33a588789d35ad27ca53dc159b406ad909f8f727
parent08cf935b84a0778fdf60992960f2c5a6dbad4d82 (diff)
downloademacs-75b7e407e8d4303930dbfad2df2f36b994f368ed.tar.gz
emacs-75b7e407e8d4303930dbfad2df2f36b994f368ed.zip
Improve doc of file-symlink-p per bug #17073.
doc/lispref/files.texi (Kinds of Files): Improve documentation of file-symlink-p. Add cross-references.
-rw-r--r--doc/lispref/ChangeLog5
-rw-r--r--doc/lispref/files.texi54
2 files changed, 51 insertions, 8 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog
index 3dfc0dffd76..bf3c6f170ea 100644
--- a/doc/lispref/ChangeLog
+++ b/doc/lispref/ChangeLog
@@ -1,3 +1,8 @@
12014-03-25 Eli Zaretskii <eliz@gnu.org>
2
3 * files.texi (Kinds of Files): Improve documentation of
4 file-symlink-p. (Bug#17073) Add cross-references.
5
12014-03-24 Barry O'Reilly <gundaetiapo@gmail.com> 62014-03-24 Barry O'Reilly <gundaetiapo@gmail.com>
2 7
3 * markers.texi (Moving Marker Positions): The 2014-03-02 doc 8 * markers.texi (Moving Marker Positions): The 2014-03-02 doc
diff --git a/doc/lispref/files.texi b/doc/lispref/files.texi
index 3818c18f57a..278b49e51e0 100644
--- a/doc/lispref/files.texi
+++ b/doc/lispref/files.texi
@@ -950,22 +950,26 @@ as directories, symbolic links, and ordinary files.
950@defun file-symlink-p filename 950@defun file-symlink-p filename
951@cindex file symbolic links 951@cindex file symbolic links
952If the file @var{filename} is a symbolic link, the 952If the file @var{filename} is a symbolic link, the
953@code{file-symlink-p} function returns the (non-recursive) link target 953@code{file-symlink-p} function returns its (non-recursive) link target
954as a string. (Determining the file name that the link points to from 954as a string. (The link target string is not necessarily the full
955the target is nontrivial.) First, this function recursively follows 955absolute file name of the target; determining the full file name that
956symbolic links at all levels of parent directories. 956the link points to is nontrivial, see below.) If the leading
957 957directories of @var{filename} include symbolic links, this function
958If the file @var{filename} is not a symbolic link (or there is no such file), 958recursively follows them.
959
960If the file @var{filename} is not a symbolic link, or does not exist,
959@code{file-symlink-p} returns @code{nil}. 961@code{file-symlink-p} returns @code{nil}.
960 962
963Here are a few examples of using this function:
964
961@example 965@example
962@group 966@group
963(file-symlink-p "foo") 967(file-symlink-p "not-a-symlink")
964 @result{} nil 968 @result{} nil
965@end group 969@end group
966@group 970@group
967(file-symlink-p "sym-link") 971(file-symlink-p "sym-link")
968 @result{} "foo" 972 @result{} "not-a-symlink"
969@end group 973@end group
970@group 974@group
971(file-symlink-p "sym-link2") 975(file-symlink-p "sym-link2")
@@ -976,6 +980,40 @@ If the file @var{filename} is not a symbolic link (or there is no such file),
976 @result{} "/pub/bin" 980 @result{} "/pub/bin"
977@end group 981@end group
978@end example 982@end example
983
984Note that in the third example, the function returned @file{sym-link},
985but did not proceed to resolve it, although that file is itself a
986symbolic link. This is what we meant by ``non-recursive'' above---the
987process of following the symbolic links does not recurse if the link
988target is itself a link.
989
990The string that this function returns is what is recorded in the
991symbolic link; it may or may not include any leading directories.
992This function does @emph{not} expand the link target to produce a
993fully-qualified file name, and in particular does not use the leading
994directories, if any, of the @var{filename} argument if the link target
995is not an absolute file name. Here's an example:
996
997@example
998@group
999(file-symlink-p "/foo/bar/baz")
1000 @result{} "some-file"
1001@end group
1002@end example
1003
1004@noindent
1005Here, although @file{/foo/bar/baz} was given as a fully-qualified file
1006name, the result is not, and in fact does not have any leading
1007directories at all. And since @file{some-file} might itself be a
1008symbolic link, you cannot simply prepend leading directories to it,
1009nor even naively use @code{expand-file-name} (@pxref{File Name
1010Expansion}) to produce its absolute file name.
1011
1012For this reason, this function is seldom useful if you need to
1013determine more than just the fact that a file is or isn't a symbolic
1014link. If you actually need the file name of the link target, use
1015@code{file-chase-links} or @code{file-truename}, described in
1016@ref{Truenames}.
979@end defun 1017@end defun
980 1018
981The next two functions recursively follow symbolic links at 1019The next two functions recursively follow symbolic links at