all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Ehud Karni" <ehud@unix.mvs.co.il>
To: emacs-devel@gnu.org
Subject: Bug in `get-free-disk-space'
Date: Sun, 5 Sep 2010 18:00:54 +0300	[thread overview]
Message-ID: <201009051500.o85F0sNU026037@beta.mvs.co.il> (raw)

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 <http://www.keyserver.net/>    Better Safe Than Sorry



             reply	other threads:[~2010-09-05 15:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-05 15:00 Ehud Karni [this message]
2010-09-05 19:03 ` Bug in `get-free-disk-space' Chong Yidong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201009051500.o85F0sNU026037@beta.mvs.co.il \
    --to=ehud@unix.mvs.co.il \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.