diff options
| author | Chong Yidong | 2010-09-05 15:03:20 -0400 |
|---|---|---|
| committer | Chong Yidong | 2010-09-05 15:03:20 -0400 |
| commit | 93a596e11b4b10e99636fce9eae2bcdf45e20c17 (patch) | |
| tree | 9522847060f2c80090c748a74f43f27b8f972494 | |
| parent | 3cf628e8ece16ccf92ab01b2e8930de4eac621e9 (diff) | |
| download | emacs-93a596e11b4b10e99636fce9eae2bcdf45e20c17.tar.gz emacs-93a596e11b4b10e99636fce9eae2bcdf45e20c17.zip | |
* files.el (get-free-disk-space): Search more robustly for "available" column.
Suggested by Ehud Karni <ehud@unix.mvs.co.il>:
http://lists.gnu.org/archive/html/emacs-devel/2010-09/msg00163.html
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/files.el | 41 |
2 files changed, 29 insertions, 18 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 69626e2e455..026b05a7231 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2010-09-05 Chong Yidong <cyd@stupidchicken.com> | ||
| 2 | |||
| 3 | * files.el (get-free-disk-space): Search more robustly for | ||
| 4 | "available" column. Suggested by Ehud Karni | ||
| 5 | <ehud@unix.mvs.co.il>. | ||
| 6 | |||
| 1 | 2010-09-05 Juanma Barranquero <lekktu@gmail.com> | 7 | 2010-09-05 Juanma Barranquero <lekktu@gmail.com> |
| 2 | 8 | ||
| 3 | * international/uni-bidi.el: | 9 | * international/uni-bidi.el: |
diff --git a/lisp/files.el b/lisp/files.el index 73a0c5c9e24..41bd9bd9c25 100644 --- a/lisp/files.el +++ b/lisp/files.el | |||
| @@ -5563,12 +5563,14 @@ preference to the program given by this variable." | |||
| 5563 | 5563 | ||
| 5564 | (defun get-free-disk-space (dir) | 5564 | (defun get-free-disk-space (dir) |
| 5565 | "Return the amount of free space on directory DIR's file system. | 5565 | "Return the amount of free space on directory DIR's file system. |
| 5566 | The result is a string that gives the number of free 1KB blocks, | 5566 | The return value is a string describing the amount of free |
| 5567 | or nil if the system call or the program which retrieve the information | 5567 | space (normally, the number of free 1KB blocks). |
| 5568 | fail. It returns also nil when DIR is a remote directory. | 5568 | |
| 5569 | 5569 | This function calls `file-system-info' if it is available, or | |
| 5570 | This function calls `file-system-info' if it is available, or invokes the | 5570 | invokes the program specified by `directory-free-space-program' |
| 5571 | program specified by `directory-free-space-program' if that is non-nil." | 5571 | and `directory-free-space-args'. If the system call or program |
| 5572 | is unsuccessful, or if DIR is a remote directory, this function | ||
| 5573 | returns nil." | ||
| 5572 | (unless (file-remote-p dir) | 5574 | (unless (file-remote-p dir) |
| 5573 | ;; Try to find the number of free blocks. Non-Posix systems don't | 5575 | ;; Try to find the number of free blocks. Non-Posix systems don't |
| 5574 | ;; always have df, but might have an equivalent system call. | 5576 | ;; always have df, but might have an equivalent system call. |
| @@ -5588,19 +5590,22 @@ program specified by `directory-free-space-program' if that is non-nil." | |||
| 5588 | directory-free-space-args | 5590 | directory-free-space-args |
| 5589 | dir) | 5591 | dir) |
| 5590 | 0))) | 5592 | 0))) |
| 5591 | ;; Usual format is a header line followed by a line of | 5593 | ;; Usual format is as follows: |
| 5592 | ;; numbers. | 5594 | ;; Filesystem ... Used Available Capacity ... |
| 5595 | ;; /dev/sda6 ...48106535 35481255 10669850 ... | ||
| 5593 | (goto-char (point-min)) | 5596 | (goto-char (point-min)) |
| 5594 | (forward-line 1) | 5597 | (when (re-search-forward " +Avail[^ \n]*" |
| 5595 | (if (not (eobp)) | 5598 | (line-end-position) t) |
| 5596 | (progn | 5599 | (let ((beg (match-beginning 0)) |
| 5597 | ;; Move to the end of the "available blocks" number. | 5600 | (end (match-end 0)) |
| 5598 | (skip-chars-forward "^ \t") | 5601 | str) |
| 5599 | (forward-word 3) | 5602 | (forward-line 1) |
| 5600 | ;; Copy it into AVAILABLE. | 5603 | (setq str |
| 5601 | (let ((end (point))) | 5604 | (buffer-substring-no-properties |
| 5602 | (forward-word -1) | 5605 | (+ beg (point) (- (point-min))) |
| 5603 | (buffer-substring (point) end)))))))))) | 5606 | (+ end (point) (- (point-min))))) |
| 5607 | (when (string-match "\\` *\\([^ ]+\\)" str) | ||
| 5608 | (match-string 1 str)))))))))) | ||
| 5604 | 5609 | ||
| 5605 | ;; The following expression replaces `dired-move-to-filename-regexp'. | 5610 | ;; The following expression replaces `dired-move-to-filename-regexp'. |
| 5606 | (defvar directory-listing-before-filename-regexp | 5611 | (defvar directory-listing-before-filename-regexp |