aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman2006-02-19 23:39:55 +0000
committerRichard M. Stallman2006-02-19 23:39:55 +0000
commit240e8be5a3709e265633dfb1015fe58f376ed865 (patch)
tree2570a18208d83fac9044829c89f68a2ea0406a5b
parentdf36a07ef048613d662365af32566abf392ffdf7 (diff)
downloademacs-240e8be5a3709e265633dfb1015fe58f376ed865.tar.gz
emacs-240e8be5a3709e265633dfb1015fe58f376ed865.zip
(Relative File Names): Move file-relative-name here.
(File Name Expansion): From here. Minor clarifications.
-rw-r--r--lispref/files.texi56
1 files changed, 29 insertions, 27 deletions
diff --git a/lispref/files.texi b/lispref/files.texi
index 36cdfa5d2bd..417bab81360 100644
--- a/lispref/files.texi
+++ b/lispref/files.texi
@@ -1770,6 +1770,32 @@ Unix syntax and VMS syntax.
1770@end example 1770@end example
1771@end defun 1771@end defun
1772 1772
1773 Given a possibly relative file name, you can convert it to an
1774absolute name using @code{expand-file-name} (@pxref{File Name
1775Expansion}). This function converts absolute file names to relative
1776names:
1777
1778@defun file-relative-name filename &optional directory
1779This function tries to return a relative name that is equivalent to
1780@var{filename}, assuming the result will be interpreted relative to
1781@var{directory} (an absolute directory name or directory file name).
1782If @var{directory} is omitted or @code{nil}, it defaults to the
1783current buffer's default directory.
1784
1785On some operating systems, an absolute file name begins with a device
1786name. On such systems, @var{filename} has no relative equivalent based
1787on @var{directory} if they start with two different device names. In
1788this case, @code{file-relative-name} returns @var{filename} in absolute
1789form.
1790
1791@example
1792(file-relative-name "/foo/bar" "/foo/")
1793 @result{} "bar"
1794(file-relative-name "/foo/bar" "/hack/")
1795 @result{} "../foo/bar"
1796@end example
1797@end defun
1798
1773@node Directory Names 1799@node Directory Names
1774@comment node-name, next, previous, up 1800@comment node-name, next, previous, up
1775@subsection Directory Names 1801@subsection Directory Names
@@ -1910,16 +1936,13 @@ you must specify the default directory name as well as the file name to
1910be expanded. Expansion also simplifies file names by eliminating 1936be expanded. Expansion also simplifies file names by eliminating
1911redundancies such as @file{./} and @file{@var{name}/../}. 1937redundancies such as @file{./} and @file{@var{name}/../}.
1912 1938
1913In the next two functions, the @var{directory} argument can be either
1914a directory name or a directory file name. @xref{Directory Names}.
1915
1916@defun expand-file-name filename &optional directory 1939@defun expand-file-name filename &optional directory
1917This function converts @var{filename} to an absolute file name. If 1940This function converts @var{filename} to an absolute file name. If
1918@var{directory} is supplied, it is the default directory to start with 1941@var{directory} is supplied, it is the default directory to start with
1919if @var{filename} is relative. (The value of @var{directory} should 1942if @var{filename} is relative. (The value of @var{directory} should
1920itself be an absolute directory name; it may start with @samp{~}.) 1943itself be an absolute directory name or directory file name; it may
1921Otherwise, the current buffer's value of @code{default-directory} is 1944start with @samp{~}.) Otherwise, the current buffer's value of
1922used. For example: 1945@code{default-directory} is used. For example:
1923 1946
1924@example 1947@example
1925@group 1948@group
@@ -1981,27 +2004,6 @@ should make sure to call @code{file-truename} without prior direct or
1981indirect calls to @code{expand-file-name}. @xref{Truenames}. 2004indirect calls to @code{expand-file-name}. @xref{Truenames}.
1982@end defun 2005@end defun
1983 2006
1984@c Emacs 19 feature
1985@defun file-relative-name filename &optional directory
1986This function does the inverse of expansion---it tries to return a
1987relative name that is equivalent to @var{filename} when interpreted
1988relative to @var{directory}. If @var{directory} is omitted or
1989@code{nil}, it defaults to the current buffer's default directory.
1990
1991On some operating systems, an absolute file name begins with a device
1992name. On such systems, @var{filename} has no relative equivalent based
1993on @var{directory} if they start with two different device names. In
1994this case, @code{file-relative-name} returns @var{filename} in absolute
1995form.
1996
1997@example
1998(file-relative-name "/foo/bar" "/foo/")
1999 @result{} "bar"
2000(file-relative-name "/foo/bar" "/hack/")
2001 @result{} "../foo/bar"
2002@end example
2003@end defun
2004
2005@defvar default-directory 2007@defvar default-directory
2006The value of this buffer-local variable is the default directory for the 2008The value of this buffer-local variable is the default directory for the
2007current buffer. It should be an absolute directory name; it may start 2009current buffer. It should be an absolute directory name; it may start