Skip to content

Commit

Permalink
Refactor out file at line with function du-file-at-line
Browse files Browse the repository at this point in the history
  • Loading branch information
pft committed Jan 16, 2010
1 parent 821d1dd commit ae86003
Showing 1 changed file with 13 additions and 21 deletions.
34 changes: 13 additions & 21 deletions disk-usage.el
Expand Up @@ -238,15 +238,17 @@ See man(du) for explanation of those arguments"
result))) result)))
"Following kB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y") "Following kB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y")



(defun du-file-at-line ()
(let ((line (buffer-substring-no-properties
(point-at-bol)
(point-at-eol))))
(string-match du-inserted-string-regex line)
(substring line (match-end 3))))

(defun du-down-dir () (defun du-down-dir ()
(interactive) (interactive)
(let* ((line (buffer-substring-no-properties (let ((file-or-dir (du-file-at-line)))
(point-at-bol)
(point-at-eol)))
(file-or-dir
(progn
(string-match du-inserted-string-regex line)
(substring line (match-end 3)))))
(if (if
(file-directory-p file-or-dir) (file-directory-p file-or-dir)
(du file-or-dir) (du file-or-dir)
Expand All @@ -256,13 +258,7 @@ See man(du) for explanation of those arguments"
(defun du-up-dir () (defun du-up-dir ()
"Go up a dir" "Go up a dir"
(interactive) (interactive)
(let* ((line (buffer-substring-no-properties (let ((file-or-dir (du-file-at-line)))
(point-at-bol)
(point-at-eol)))
(file-or-dir
(progn
(string-match du-inserted-string-regex line)
(substring line (match-end 3)))))
(du (du
(file-name-directory (file-name-directory
(substring file-or-dir (substring file-or-dir
Expand All @@ -274,18 +270,14 @@ See man(du) for explanation of those arguments"
(define-key m [(:)] 'du-up-dir) (define-key m [(:)] 'du-up-dir)
(define-key m [(d)] 'du-dired) (define-key m [(d)] 'du-dired)
(define-key m [(q)] 'bury-buffer) (define-key m [(q)] 'bury-buffer)
(define-key m [(u)] 'du)
(define-key m [(D)] 'du-delete)
m)) m))


(defun du-dired () (defun du-dired ()
"View dir in dired" "View dir in dired"
(interactive) (interactive)
(let* ((line (buffer-substring-no-properties (let ((file-or-dir (du-file-at-line)))
(point-at-bol)
(point-at-eol)))
(file-or-dir
(progn
(string-match du-inserted-string-regex line)
(substring line (match-end 3)))))
(dired (dired
(if (file-directory-p file-or-dir) (if (file-directory-p file-or-dir)
file-or-dir file-or-dir
Expand Down

0 comments on commit ae86003

Please sign in to comment.