diff options
| author | Paul Eggert | 2017-10-01 22:31:39 -0700 |
|---|---|---|
| committer | Paul Eggert | 2017-10-01 22:33:20 -0700 |
| commit | 135bca574c31b7bf6df6c63d28f180956928dde7 (patch) | |
| tree | 1259c514b5304e7b1dbb8a9098f0a6dd63e00003 /lisp | |
| parent | 4829a3b033b119b088947d14b73efc197b2547fa (diff) | |
| download | emacs-135bca574c31b7bf6df6c63d28f180956928dde7.tar.gz emacs-135bca574c31b7bf6df6c63d28f180956928dde7.zip | |
Port file-system-info to non-Microsoft
* admin/merge-gnulib (GNULIB_MODULES): Add fsusage.
* doc/emacs/files.texi (Directories): Remove documentation of
now-obsolete directory-free-space-program and
directory-free-space-args.
* etc/NEWS: Mention change.
* etc/PROBLEMS: Slow df is no longer a problem.
* lib/fsusage.c, lib/fsusage.h, m4/fsusage.m4:
New files, copied from Gnulib.
* lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate.
* lisp/dired.el (dired-free-space-program)
(dired-free-space-args): These aliases are now obsolete.
* lisp/files.el (directory-free-space-program)
(directory-free-space-args): Now obsolete.
(get-free-disk-space): Just call file-system-info instead
of the now-obsolete directory-free-space-program.
* nt/gnulib-cfg.mk (OMIT_GNULIB_MODULE_fsusage): New macro.
* src/fileio.c: Include fsusage.h.
(blocks_to_bytes, Ffile_system_info) [!DOS_NT]: New functions.
(syms_of_fileio) [!DOS_NT]: Defsubr file-system-info.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/dired.el | 6 | ||||
| -rw-r--r-- | lisp/files.el | 49 |
2 files changed, 16 insertions, 39 deletions
diff --git a/lisp/dired.el b/lisp/dired.el index 9e09d349f7c..1ec3ac4f99c 100644 --- a/lisp/dired.el +++ b/lisp/dired.el | |||
| @@ -198,8 +198,10 @@ The target is used in the prompt for file copy, rename etc." | |||
| 198 | 198 | ||
| 199 | ; These variables were deleted and the replacements are on files.el. | 199 | ; These variables were deleted and the replacements are on files.el. |
| 200 | ; We leave aliases behind for back-compatibility. | 200 | ; We leave aliases behind for back-compatibility. |
| 201 | (defvaralias 'dired-free-space-program 'directory-free-space-program) | 201 | (define-obsolete-variable-alias 'dired-free-space-program |
| 202 | (defvaralias 'dired-free-space-args 'directory-free-space-args) | 202 | 'directory-free-space-program "27.1") |
| 203 | (define-obsolete-variable-alias 'dired-free-space-args | ||
| 204 | 'directory-free-space-args "27.1") | ||
| 203 | 205 | ||
| 204 | ;;; Hook variables | 206 | ;;; Hook variables |
| 205 | 207 | ||
diff --git a/lisp/files.el b/lisp/files.el index 336bbc8648d..194c87ab680 100644 --- a/lisp/files.el +++ b/lisp/files.el | |||
| @@ -6386,58 +6386,33 @@ if you want to specify options, use `directory-free-space-args'. | |||
| 6386 | 6386 | ||
| 6387 | A value of nil disables this feature. | 6387 | A value of nil disables this feature. |
| 6388 | 6388 | ||
| 6389 | If the function `file-system-info' is defined, it is always used in | 6389 | This variable is obsolete; Emacs no longer uses it." |
| 6390 | preference to the program given by this variable." | ||
| 6391 | :type '(choice (string :tag "Program") (const :tag "None" nil)) | 6390 | :type '(choice (string :tag "Program") (const :tag "None" nil)) |
| 6392 | :group 'dired) | 6391 | :group 'dired) |
| 6392 | (make-obsolete-variable 'directory-free-space-program | ||
| 6393 | "ignored, as Emacs uses `file-system-info' instead" | ||
| 6394 | "27.1") | ||
| 6393 | 6395 | ||
| 6394 | (defcustom directory-free-space-args | 6396 | (defcustom directory-free-space-args |
| 6395 | (purecopy (if (eq system-type 'darwin) "-k" "-Pk")) | 6397 | (purecopy (if (eq system-type 'darwin) "-k" "-Pk")) |
| 6396 | "Options to use when running `directory-free-space-program'." | 6398 | "Options to use when running `directory-free-space-program'." |
| 6397 | :type 'string | 6399 | :type 'string |
| 6398 | :group 'dired) | 6400 | :group 'dired) |
| 6401 | (make-obsolete-variable 'directory-free-space-args | ||
| 6402 | "ignored, as Emacs uses `file-system-info' instead" | ||
| 6403 | "27.1") | ||
| 6399 | 6404 | ||
| 6400 | (defun get-free-disk-space (dir) | 6405 | (defun get-free-disk-space (dir) |
| 6401 | "Return the amount of free space on directory DIR's file system. | 6406 | "Return the amount of free space on directory DIR's file system. |
| 6402 | The return value is a string describing the amount of free | 6407 | The return value is a string describing the amount of free |
| 6403 | space (normally, the number of free 1KB blocks). | 6408 | space (normally, the number of free 1KB blocks). |
| 6404 | 6409 | ||
| 6405 | This function calls `file-system-info' if it is available, or | 6410 | If DIR's free space cannot be obtained, or if DIR is a remote |
| 6406 | invokes the program specified by `directory-free-space-program' | 6411 | directory, this function returns nil." |
| 6407 | and `directory-free-space-args'. If the system call or program | ||
| 6408 | is unsuccessful, or if DIR is a remote directory, this function | ||
| 6409 | returns nil." | ||
| 6410 | (unless (file-remote-p (expand-file-name dir)) | 6412 | (unless (file-remote-p (expand-file-name dir)) |
| 6411 | ;; Try to find the number of free blocks. Non-Posix systems don't | 6413 | (let ((avail (nth 2 (file-system-info dir)))) |
| 6412 | ;; always have df, but might have an equivalent system call. | 6414 | (if avail |
| 6413 | (if (fboundp 'file-system-info) | 6415 | (format "%.0f" (/ avail 1024)))))) |
| 6414 | (let ((fsinfo (file-system-info dir))) | ||
| 6415 | (if fsinfo | ||
| 6416 | (format "%.0f" (/ (nth 2 fsinfo) 1024)))) | ||
| 6417 | (setq dir (expand-file-name dir)) | ||
| 6418 | (save-match-data | ||
| 6419 | (with-temp-buffer | ||
| 6420 | (when (and directory-free-space-program | ||
| 6421 | ;; Avoid failure if the default directory does | ||
| 6422 | ;; not exist (Bug#2631, Bug#3911). | ||
| 6423 | (let ((default-directory | ||
| 6424 | (locate-dominating-file dir 'file-directory-p))) | ||
| 6425 | (eq (process-file directory-free-space-program | ||
| 6426 | nil t nil | ||
| 6427 | directory-free-space-args | ||
| 6428 | (file-relative-name dir)) | ||
| 6429 | 0))) | ||
| 6430 | ;; Assume that the "available" column is before the | ||
| 6431 | ;; "capacity" column. Find the "%" and scan backward. | ||
| 6432 | (goto-char (point-min)) | ||
| 6433 | (forward-line 1) | ||
| 6434 | (when (re-search-forward | ||
| 6435 | "[[:space:]]+[^[:space:]]+%[^%]*$" | ||
| 6436 | (line-end-position) t) | ||
| 6437 | (goto-char (match-beginning 0)) | ||
| 6438 | (let ((endpt (point))) | ||
| 6439 | (skip-chars-backward "^[:space:]") | ||
| 6440 | (buffer-substring-no-properties (point) endpt))))))))) | ||
| 6441 | 6416 | ||
| 6442 | ;; The following expression replaces `dired-move-to-filename-regexp'. | 6417 | ;; The following expression replaces `dired-move-to-filename-regexp'. |
| 6443 | (defvar directory-listing-before-filename-regexp | 6418 | (defvar directory-listing-before-filename-regexp |