From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Ehud Karni" Newsgroups: gmane.emacs.devel Subject: Bug in `get-free-disk-space' Date: Sun, 5 Sep 2010 18:00:54 +0300 Organization: Mivtach-Simon Insurance agencies Message-ID: <201009051500.o85F0sNU026037@beta.mvs.co.il> Reply-To: ehud@unix.mvs.co.il NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1283698901 20834 80.91.229.12 (5 Sep 2010 15:01:41 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 5 Sep 2010 15:01:41 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Sep 05 17:01:40 2010 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OsGix-0002lT-UC for ged-emacs-devel@m.gmane.org; Sun, 05 Sep 2010 17:01:40 +0200 Original-Received: from localhost ([127.0.0.1]:53825 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OsGix-0004Ps-HB for ged-emacs-devel@m.gmane.org; Sun, 05 Sep 2010 11:01:39 -0400 Original-Received: from [140.186.70.92] (port=41017 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OsGiq-0004OG-A8 for emacs-devel@gnu.org; Sun, 05 Sep 2010 11:01:33 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OsGip-0007z8-27 for emacs-devel@gnu.org; Sun, 05 Sep 2010 11:01:32 -0400 Original-Received: from [193.16.147.12] (port=50737 helo=unix.mvs.co.il) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OsGio-0007yU-Cd for emacs-devel@gnu.org; Sun, 05 Sep 2010 11:01:30 -0400 Original-Received: from beta.mvs.co.il (beta [10.253.0.3]) by unix.mvs.co.il (8.13.8/8.13.7) with ESMTP id o85F0s7g009032 for ; Sun, 5 Sep 2010 18:01:06 +0300 Original-Received: from beta.mvs.co.il (localhost [127.0.0.1]) by beta.mvs.co.il (8.14.1/8.14.1) with ESMTP id o85F0s1H026040 for ; Sun, 5 Sep 2010 18:00:54 +0300 Original-Received: (from root@localhost) by beta.mvs.co.il (8.14.1/8.14.1/Submit) id o85F0sNU026037 for emacs-devel@gnu.org; Sun, 5 Sep 2010 18:00:54 +0300 X-Mailer: Emacs 21.3.1 rmail (send-msg 1.109) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:129692 Archived-At: When the mount name has a space or `directory-free-space-args' is set to "-h" (human readable format), `get-free-disk-space' in lisp/files.el gives wrong results: example of `df -h' with spaces in the mount name: Filesystem Size Used Avail Use% Mounted on /dev/md/d0p2 2.7T 1.7T 1.1T 61% /RAID //dc-2000-xp/ehuds D 172G 169G 2.8G 99% /ehuds/D //dc-2000-xp/ehuds U - Gibuy 233G 228G 5.2G 98% /ehuds/U The patch bellow (against trunc/lisp/files.el) fix this problem and adds units to the use and available values. Ehud. diff -c /f-s/gnu/src/emacs-bzr/trunk/lisp/files.el-org /f-s/gnu/src/emacs-bzr/trunk/lisp/files.el *** /f-s/gnu/src/emacs-bzr/trunk/lisp/files.el-org Wed Sep 1 18:47:47 2010 --- /f-s/gnu/src/emacs-bzr/trunk/lisp/files.el Sun Sep 5 15:52:28 2010 *************** *** 5594,5606 **** (forward-line 1) (if (not (eobp)) (progn ! ;; Move to the end of the "available blocks" number. ! (skip-chars-forward "^ \t") ! (forward-word 3) ! ;; Copy it into AVAILABLE. (let ((end (point))) ! (forward-word -1) ! (buffer-substring (point) end)))))))))) ;; The following expression replaces `dired-move-to-filename-regexp'. (defvar directory-listing-before-filename-regexp --- 5594,5613 ---- (forward-line 1) (if (not (eobp)) (progn ! ! ;; example of `df -h' with spaces in the mount name ! ;; Filesystem Size Used Avail Use% Mounted on ! ;; /dev/md/d0p2 2.7T 1.7T 1.1T 61% /RAID ! ;; //dc-2000-xp/ehuds D 172G 169G 2.8G 99% /ehuds/D ! ;; //dc-2000-xp/ehuds U - Gibuy ! ;; 233G 228G 5.2G 98% /ehuds/U ! ;; use the % as an anchor ! (search-forward "%") ! (skip-chars-backward "%[0-9]") ! (skip-chars-backward " ") (let ((end (point))) ! (skip-chars-backward ".[0-9][A-Z]") ! (buffer-substring (point) end)))))))))) ;; The following expression replaces `dired-move-to-filename-regexp'. (defvar directory-listing-before-filename-regexp *************** *** 5936,5942 **** ;; Replace "total" with "used", to avoid confusion. (replace-match "total used in directory" nil nil nil 1) (end-of-line) ! (insert " available " available)))))))))) (defun insert-directory-adj-pos (pos error-lines) "Convert `ls --dired' file name position value POS to a buffer position. --- 5943,5952 ---- ;; Replace "total" with "used", to avoid confusion. (replace-match "total used in directory" nil nil nil 1) (end-of-line) ! (insert " KB, available " available ! (if (string-match "[A-Z]" available) "" ! (if (string-match "m" directory-free-space-args) ! " MB" " KB")))))))))))) (defun insert-directory-adj-pos (pos error-lines) "Convert `ls --dired' file name position value POS to a buffer position. -- Ehud Karni Tel: +972-3-7966-561 /"\ Mivtach - Simon Fax: +972-3-7976-561 \ / ASCII Ribbon Campaign Insurance agencies (USA) voice mail and X Against HTML Mail http://www.mvs.co.il FAX: 1-815-5509341 / \ GnuPG: 98EA398D Better Safe Than Sorry