Skip to content

Latest commit

 

History

History
59 lines (43 loc) · 1.8 KB

ls--dired.org

File metadata and controls

59 lines (43 loc) · 1.8 KB

了解 ls –dired

GNU Coreutils 的 ls 专门为 GNU Emacs 提供了 –dired 选项。

  1. –dired 是干嘛的,为什么要有?
  2. ls –dired 的输出是什么格式?
  3. Dired 是如何解析上面的格式的?
  4. 自己打印 ls –dired 的输出
  5. 自己解析 ls –dired 的输出

–dired 的作用以及格式

(info “(coreutils) What information is listed”) 解释清楚了,就是让 Dired 能准确地找出文件名:

gls --dired -l *.el

45 54 表示第一个文件 custom.el,依此类推。

Dired 是如何处理的?

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

实现和解析 ls –dired