emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r101618: * files.el (get-free-disk-sp


From: Chong Yidong
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r101618: * files.el (get-free-disk-space): Don't assume "df" output columns line up (Bug#6995).
Date: Sat, 25 Sep 2010 16:16:35 -0400
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 101618
committer: Chong Yidong <address@hidden>
branch nick: trunk
timestamp: Sat 2010-09-25 16:16:35 -0400
message:
  * files.el (get-free-disk-space): Don't assume "df" output columns line up 
(Bug#6995).
modified:
  lisp/ChangeLog
  lisp/files.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2010-09-25 12:04:35 +0000
+++ b/lisp/ChangeLog    2010-09-25 20:16:35 +0000
@@ -1,3 +1,8 @@
+2010-09-25  Chong Yidong  <address@hidden>
+
+       * files.el (get-free-disk-space): Don't assume the "df" output
+       columns line up (Bug#6995).
+
 2010-09-25  Juanma Barranquero  <address@hidden>
 
        * finder.el (finder-unknown-keywords):

=== modified file 'lisp/files.el'
--- a/lisp/files.el     2010-09-24 03:06:33 +0000
+++ b/lisp/files.el     2010-09-25 20:16:35 +0000
@@ -5622,22 +5622,17 @@
                                         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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]