From: Chong Yidong Date: Sat, 25 Sep 2010 20:16:35 +0000 (-0400) Subject: * files.el (get-free-disk-space): Don't assume "df" output columns line up (Bug#6995). X-Git-Tag: emacs-pretest-24.0.90~104^2~275^2~438^2~47^2~42^2~21 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=41f54b738882c1f98c152c7788c2c2456993531b;p=emacs.git * files.el (get-free-disk-space): Don't assume "df" output columns line up (Bug#6995). --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index c220f46509d..8adb6b03de6 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2010-09-25 Chong Yidong + + * files.el (get-free-disk-space): Don't assume the "df" output + columns line up (Bug#6995). + 2010-09-25 Juanma Barranquero * finder.el (finder-unknown-keywords): diff --git a/lisp/files.el b/lisp/files.el index 24190a51529..40627f690f8 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -5622,22 +5622,17 @@ returns nil." directory-free-space-args dir) 0))) - ;; Usual format is as follows: - ;; Filesystem ... Used Available Capacity ... - ;; /dev/sda6 ...48106535 35481255 10669850 ... + ;; Assume that the "available" column is before the + ;; "capacity" column. Find the "%" and scan backward. (goto-char (point-min)) - (when (re-search-forward " +Avail[^ \n]*" - (line-end-position) t) - (let ((beg (match-beginning 0)) - (end (match-end 0)) - str) - (forward-line 1) - (setq str - (buffer-substring-no-properties - (+ beg (point) (- (point-min))) - (+ end (point) (- (point-min))))) - (when (string-match "\\` *\\([^ ]+\\)" str) - (match-string 1 str)))))))))) + (forward-line 1) + (when (re-search-forward + "[[:space:]]+[^[:space:]]+%[^%]*$" + (line-end-position) t) + (goto-char (match-beginning 0)) + (let ((endpt (point))) + (skip-chars-backward "^[:space:]") + (buffer-substring-no-properties (point) endpt))))))))) ;; The following expression replaces `dired-move-to-filename-regexp'. (defvar directory-listing-before-filename-regexp