summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Albinus <michael.albinus@gmx.de>2017-10-03 16:15:08 +0200
committerMichael Albinus <michael.albinus@gmx.de>2017-10-03 16:15:08 +0200
commit92045f4546b9708dc9f69954799d211c1f56ff1e (patch)
tree3da042d305f9a7ef78c1ee9e49463f13db3900ba
parentf204e6e1a418073bd1e24a83947f1f3c53581c7f (diff)
downloademacs-92045f4546b9708dc9f69954799d211c1f56ff1e.tar.gz
Add file name handler support for file-system-info
* doc/lispref/files.texi (Magic File Names): Add file-system-info. * etc/NEWS: Mention get-free-disk-space working on remote systems. * lisp/files.el (get-free-disk-space): Do not block on remote systems. * src/w32fns.c (Ffile_system_info): * src/fileio.c (Ffile_system_info): Call file name handler if exists. (syms_of_fileio): Add Qfile_system_info.
-rw-r--r--doc/lispref/files.texi6
-rw-r--r--etc/NEWS8
-rw-r--r--lisp/files.el10
-rw-r--r--src/fileio.c13
-rw-r--r--src/w32fns.c11
5 files changed, 39 insertions, 9 deletions
diff --git a/doc/lispref/files.texi b/doc/lispref/files.texi
index 0a37eeb2a85..0f0ce157cad 100644
--- a/doc/lispref/files.texi
+++ b/doc/lispref/files.texi
@@ -3135,7 +3135,8 @@ first, before handlers for jobs such as remote file access.
@code{file-ownership-preserved-p},
@code{file-readable-p}, @code{file-regular-p},
@code{file-remote-p}, @code{file-selinux-context},
-@code{file-symlink-p}, @code{file-truename}, @code{file-writable-p},
+@code{file-symlink-p}, @code{file-system-info},
+@code{file-truename}, @code{file-writable-p},
@code{find-backup-file-name},@*
@code{get-file-buffer},
@code{insert-directory},
@@ -3191,7 +3192,8 @@ first, before handlers for jobs such as remote file access.
@code{file-ownership-pre@discretionary{}{}{}served-p},
@code{file-readable-p}, @code{file-regular-p},
@code{file-remote-p}, @code{file-selinux-context},
-@code{file-symlink-p}, @code{file-truename}, @code{file-writable-p},
+@code{file-symlink-p}, @code{file-system-info},
+@code{file-truename}, @code{file-writable-p},
@code{find-backup-file-name},
@code{get-file-buffer},
@code{insert-directory},
diff --git a/etc/NEWS b/etc/NEWS
index 28789a956ae..15661808c76 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -70,13 +70,19 @@ Programs that called it with multiple arguments before should pass
them through 'format' first. Even that is discouraged: for ElDoc
support, you should set 'eldoc-documentation-function' instead of
calling 'eldoc-message' directly.
+
* Lisp Changes in Emacs 27.1
+---
** The 'file-system-info' function is now available on all platforms.
-instead of just Microsoft platforms. This fixes a get-free-disk-space
+instead of just Microsoft platforms. This fixes a 'get-free-disk-space'
bug on OS X 10.8 and later (Bug#28639).
+---
+** The function 'get-free-disk-space' returns now a non-nil value for
+remote systems, which support this check.
+
* Changes in Emacs 27.1 on Non-Free Operating Systems
diff --git a/lisp/files.el b/lisp/files.el
index 194c87ab680..666654da2c9 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -6407,12 +6407,10 @@ This variable is obsolete; Emacs no longer uses it."
The return value is a string describing the amount of free
space (normally, the number of free 1KB blocks).
-If DIR's free space cannot be obtained, or if DIR is a remote
-directory, this function returns nil."
- (unless (file-remote-p (expand-file-name dir))
- (let ((avail (nth 2 (file-system-info dir))))
- (if avail
- (format "%.0f" (/ avail 1024))))))
+If DIR's free space cannot be obtained, this function returns nil."
+ (let ((avail (nth 2 (file-system-info dir))))
+ (if avail
+ (format "%.0f" (/ avail 1024)))))
;; The following expression replaces `dired-move-to-filename-regexp'.
(defvar directory-listing-before-filename-regexp
diff --git a/src/fileio.c b/src/fileio.c
index 11370279d1b..d460f123a82 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -5789,6 +5789,18 @@ If the underlying system call fails, value is nil. */)
(Lisp_Object filename)
{
Lisp_Object encoded = ENCODE_FILE (Fexpand_file_name (filename, Qnil));
+
+ /* If the file name has special constructs in it,
+ call the corresponding file handler. */
+ Lisp_Object handler = Ffind_file_name_handler (encoded, Qfile_system_info);
+ if (!NILP (handler))
+ {
+ Lisp_Object result = call2 (handler, Qfile_system_info, encoded);
+ if (CONSP (result) || NILP (result))
+ return result;
+ error ("Invalid handler in `file-name-handler-alist'");
+ }
+
struct fs_usage u;
if (get_fs_usage (SSDATA (encoded), NULL, &u) != 0)
return Qnil;
@@ -5870,6 +5882,7 @@ syms_of_fileio (void)
DEFSYM (Qwrite_region, "write-region");
DEFSYM (Qverify_visited_file_modtime, "verify-visited-file-modtime");
DEFSYM (Qset_visited_file_modtime, "set-visited-file-modtime");
+ DEFSYM (Qfile_system_info, "file-system-info");
/* The symbol bound to coding-system-for-read when
insert-file-contents is called for recovering a file. This is not
diff --git a/src/w32fns.c b/src/w32fns.c
index efbd81b22d9..e3de22d68ab 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -9336,6 +9336,17 @@ If the underlying system call fails, value is nil. */)
filename = Fexpand_file_name (filename, Qnil);
encoded = ENCODE_FILE (filename);
+ /* If the file name has special constructs in it,
+ call the corresponding file handler. */
+ Lisp_Object handler = Ffind_file_name_handler (encoded, Qfile_system_info);
+ if (!NILP (handler))
+ {
+ value = call2 (handler, Qfile_system_info, encoded);
+ if (CONSP (value) || NILP (value))
+ return value;
+ error ("Invalid handler in `file-name-handler-alist'");
+ }
+
value = Qnil;
/* Determining the required information on Windows turns out, sadly,