[Top][All Lists]

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

dired and BLOCK_SIZE

From: Craig Lawson
Subject: dired and BLOCK_SIZE
Date: 9 Apr 2001 04:42:11 GMT

  Emacs dired mode does not work well when the BLOCK_SIZE environment
variable is set. BLOCK_SIZE changes ls, du, and df to display file
sizes in scientific units rather than in bytes. It's a nice feature
with large files and big disks.
  Anyway, dired doesn't handle it well. Symptoms are: on a line where
a file is 1K or larger, the cursor is positioned at the beginning of
the line, not at the beginning of the file name like it's supposed
to. Also, dired commands do not work on those files dired doesn't
  Add the code below to your .emacs start-up file, and you will be
able to use dired with BLOCK_SIZE.

(add-hook 'dired-load-hook
          (lambda ()
            (if (equal ".*[0-9] "
                       (substring dired-move-to-filename-regexp 0 8))
                (setq dired-move-to-filename-regexp
                      (concat ".*[0-9]\\(\\([.][0-9]+\\)?[kMGTPEZY]\\)? "
                              (substring dired-move-to-filename-regexp 8))
                      )) ))

  The code above doctors the beginning of the
dired-move-to-filename-regexp variable. Although it could have been
written to simply setq the regexp (and originally was), I changed it
to test the regexp format. It only changes the regexp if it can
recognize the problematic part of the regexp (so if someone changes
the regexp to something else later, this code will not cause damage).
  Also, I did not want to include the entire regexp in this e-mail
because it is long and contains non-printable characters.
  The code is not invoked until you use actually use dired.

  And now for some gratuitous keywords for search engines:

Craig Lawson

reply via email to

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