unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Bug in `get-free-disk-space'
@ 2010-09-05 15:00 Ehud Karni
  2010-09-05 19:03 ` Chong Yidong
  0 siblings, 1 reply; 2+ messages in thread
From: Ehud Karni @ 2010-09-05 15:00 UTC (permalink / raw)
  To: emacs-devel

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



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Bug in `get-free-disk-space'
  2010-09-05 15:00 Bug in `get-free-disk-space' Ehud Karni
@ 2010-09-05 19:03 ` Chong Yidong
  0 siblings, 0 replies; 2+ messages in thread
From: Chong Yidong @ 2010-09-05 19:03 UTC (permalink / raw)
  To: ehud; +Cc: emacs-devel

"Ehud Karni" <ehud@unix.mvs.co.il> writes:

> 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

Thanks.  I've checked a slightly different fix into the trunk.



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-09-05 19:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-05 15:00 Bug in `get-free-disk-space' Ehud Karni
2010-09-05 19:03 ` Chong Yidong

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).