GNU Coreutils 的 ls 专门为 GNU Emacs 提供了 –dired 选项。
- –dired 是干嘛的,为什么要有?
- ls –dired 的输出是什么格式?
- Dired 是如何解析上面的格式的?
- 自己打印 ls –dired 的输出
- 自己解析 ls –dired 的输出
(info “(coreutils) What information is listed”) 解释清楚了,就是让 Dired 能准确地找出文件名:
gls --dired -l *.el
45 54 表示第一个文件 custom.el,依此类推。
Dired 用到的 insert-directory
会处理 –dired
(with-temp-buffer
(insert-directory "." "-l --dired" nil t)
(forward-line -1)
(format "%S" (buffer-substring (point) (point-max))))
insert-directory-clean
会把 //DIRED// BEG1 END1 BEG2 END2 ...
转换成 dired-filename text propertize
dired -> dired-insert-directory -> insert-directory -> insert-directory-clean -> insert-directory-adj-pos
dired-filename 属性是 Dired 的核心。
dired -> dired-insert-set-properties -> dired-move-to-filename