eza-community / eza

A modern, maintained replacement for ls
https://eza.rocks
MIT License
8.76k stars 171 forks source link

feat: Adding Emacs Dired Support #1007

Open lajoskvcs opened 1 month ago

lajoskvcs commented 1 month ago

Original issue: https://github.com/ogham/exa/issues/1143

Emacs has a built in tool for viewing files/directories called Dired and GNU Coreutils has the --dired option within ls to complement that.

Man page states:

-D, --dired              generate output designed for Emacs' dired mode

And from their comments in source file it seems like this option formats the output differently for easier parsing in emacs.

Would be nice to have this baked in into exa as well.

Github mirror: https://github.com/coreutils/coreutils ls file: https://github.com/coreutils/coreutils/blob/master/src/ls.c

tertsdiepraam commented 1 month ago

I can give some additional context to this with my uutils hat on. --dired essentially is the same as --long, but it keeps track of the bytes at which the filenames have been written. This is then read by Emacs to allow navigating that list of files without actually parsing the output of ls (note how C-n and C-p jump to the filename).

Before adding this, I would first investigate whether there is any prior art for alternative ls-like programs that can be used from dired, because it seems written very tightly for ls including its formatting and the options it passes to ls.

In my opinion, this seems superfluous even in ls, because it's adapting to one specific program. It's very much GNU implementing a feature specifically for themselves because they wanted a shortcut for implementing dired, which they probably should have just baked into the editor. Whatever you do, don't keep track of all the written bytes by hand, that gets super messy really quickly (and I still have to refactor this in uutils 😄).

mmarshall540 commented 3 weeks ago

which they probably should have just baked into the editor.

They actually did. You can use Emacs's baked-in version on systems that don't have ls. But it's slower than running the system's native ls when that's available.

Folks who want Dired's output to look more like eza should probably install nerd-icons.el and maybe some other Emacs packages to directly enhance Dired.