-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathee-dired.el
executable file
·126 lines (97 loc) · 3.83 KB
/
ee-dired.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
;;; ee-dired.el --- categorized directory listings
;; Copyright (C) 2002, 2003, 2004, 2010 Juri Linkov <[email protected]>
;; Author: Juri Linkov <[email protected]>
;; Keywords: ee
;; This file is [not yet] part of GNU Emacs.
;; This package is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; This package is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this package; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;; Commentary:
;; See the file README and documentation for more information.
;;; Code:
(require 'ee)
;;; Constants
(defconst ee-dired-mode-name "ee-dired")
;;; Customizable Variables
(defgroup ee-dired nil
"Categorized directory listings."
:prefix "ee-dired-"
:group 'ee)
;;; Data Description
(defvar ee-dired-data
'[(meta
(format-version . "0.0.1")
(view-data-file . "view/dired.ee")
(collector . ee-dired-data-collect)
(fields file-name directory uid gid modtime size modes ())
(key-fields name))])
;;; Data Extraction
(defun ee-dired-data-collect (data)
(let ((new-data (ee-data-convert-lists-to-vectors
(ee-dired-data-collect-files
(ee-data-field-names data)
(expand-file-name ".")))))
(aset new-data 0 (aref data 0))
new-data))
(defun ee-dired-data-collect-files (field-names dir)
(if (file-directory-p dir)
(mapcan
(lambda (filename)
(let ((fullname (concat dir filename)))
(cond
((member filename '("." ".."))
nil)
((file-directory-p fullname)
(ee-dired-data-collect-files
field-names fullname))
((file-exists-p fullname)
(let ((attr (file-attributes fullname)))
(list (mapcar (lambda (field-name)
(cond
((eq field-name 'file-name) filename)
((eq field-name 'directory) (file-name-directory fullname))
((eq field-name 'uid) (nth 2 attr))
((eq field-name 'gid) (nth 3 attr))
((eq field-name 'modtime) (nth 5 attr))
((eq field-name 'size) (nth 7 attr))
((eq field-name 'modes) (nth 8 attr))))
field-names)))))))
(directory-files (setq dir (file-name-as-directory dir)) nil nil t))))
;;; Actions
(defun ee-dired-find-file (&optional arg)
(interactive)
(find-file (expand-file-name (ee-field 'file-name) (ee-field 'directory))))
;;; Key Bindings
(defvar ee-dired-keymap nil
"Local keymap for ee-dired mode.")
(defun ee-dired-keymap-make-default ()
"Defines default key bindings for `ee-dired-keymap'.
It inherits key bindings from `ee-mode-map'."
(or ee-mode-map
(ee-mode-map-make-default))
(let ((map (copy-keymap ee-mode-map)))
;; (define-key map "\C-o" 'ee-dired-start-process)
(setq ee-dired-keymap map)))
(or ee-dired-keymap
(ee-dired-keymap-make-default))
;;; Top-Level Functions
;;;###autoload
(defun ee-dired (&optional arg)
"Categorized directory listings."
(interactive "P")
(ee-view-buffer-create
(format "*%s*%s" ee-dired-mode-name (expand-file-name "."))
ee-dired-mode-name
ee-dired-keymap
ee-dired-data))
(provide 'ee-dired)
;;; ee-dired.el ends here