Have never felt the need for anything beyond that.
For example, if I'm editing a file called originalfilename.txt, and I decide it should be called newfilename.txt, I can mv originalfilename.txt newfilename.txt in the terminal and it's all good, but you're still editing the buffer originalfilename.txt in emacs and if you save it you will have a new file with that name.
Using dired to change the filename updates all the buffers that are using that file.
dired gets some hate, I think because it creates a lot of buffers and they tend to stick around, but it's never bothered me.
On the occasion where I'm even tempted to interact with a list of files, it seems easier to do
git diff development --name-only | gci | ocgv | sco -exp fullname | xargs e
And then pick from the list and boom, they're all in buffers. I mean, sure, that's because I set it up that way (in particular the emacsclient wrapper e, which does other smart things like find the TRAMP server, etc. etc.), and presumably there's an equivalent in dired but the distance from here to there seems paved with a lot of clunkiness. The nice thing about using the shell is that I can add to or subtract from these expressions and manipulations at will.There's a variable in recent versions of emacs that deals with that
dired-kill-when-opening-new-dired-buffer
I'm glad it's a switch, though. I set it to true, but I can see someone being used to the dired command to go to a specific directory, and then manage things with dired-insert-subdir.I didn't need a replacement for Windows Explorer, until I tried Linux (bash, really) out of boredom/curiosity, and now I can't imagine going back.
Could be that there's another step up. And we can't see it from where we are standing.
Dired stands for directory editing.
One of my favourite features of Dired is the ability to mark or unmark multiple files in a variety of ways: manually, using repetition counts, or with regular expressions. This can be done fluidly and spontaneously as we browse and inspect files. Once we're satisfied with our selection, we can perform bulk operations on them such as copying, moving, deleting, changing permission bits, compressing the marked files, etc.
It's a bit like how we can use a GUI desktop environment to mark multiple files and then perform bulk operations on them. This is something we cannot easily do on the shell with the standard Unix utilities. But we can do all of this from within Emacs using very concise sequence of keystrokes and muscle memory.
Further, unlike most GUI desktop environments, every Dired interaction is scriptable, recordable, and replayable. I mean every operation or key sequence in Dired is available as an Elisp function, so we can script repetitive tasks by writing small Elisp snippets. Or, alternatively, we can have Emacs record the repetitive actions as keyboard macros, which we can then replay as many times as needed. I no longer have to worry whether the underlying GUI desktop environment supports these features or not because I know Emacs does and I can just use Emacs to browse my system.
And that brings me to another important benefit of using Dired: my muscle memory for Dired is transferable across a wide variety of systems and environments. It doesn't matter whether I'm working locally or logged into a remote shell, or whether I'm on macOS, Xfce4, KDE, etc. I can browse and edit my files and directories in exactly the same way using the same muscle memory and the same set of Dired commands, key sequences, and features!
A couple of years ago, I used to host Emacs book club meetings. I've kept some notes on directory editing with Dired from those sessions here: <https://susam.net/cc/mastering-emacs/ch06.html#dired>.
Not to get too deep into this, but there’s this warm fuzzy feeling of not having to use /yet another different app/ that’s ever so slightly different to the optimal workflow you have otherwise
For example: I never thought of using total commander to augment some custom hotkey in vim. But in Emacs it’s just another set of functions available right there.
That does sound cool. Emacs sounds like the type of app I would have loved back when DOS was still a thing, but now after using linux for 20 something years, the fact that it can do everything just seems so antithetical to the unix way...even if I could see myself using it, the idea of being so dependent on one app for so much seems so weird to me these days. Guess I'll be sticking with vim and various cli tools until the end of time.
Emacs also eschews the "everything is a file" philosophy of unix (programs in emacs are just lisp functions) and the idea of storing / transmitting data as plain text, instead using lisp data structures to do that.
Lisp itself is kind of antithetical to the unix philosophy too when compared with C. Lisp is presents an extremely simple, totally consistent core that is extremely difficult to implement efficient compilers for. C on the other hand was designed from the outset with the goal of being easy to write compilers for. Requirements for having function prototypes ahead of uses, having all variables declared at the top of a function, etc were done to make it easier to implement. Almost a perfect example of worse is better, really.
Check out the unix hater's handbook if you haven't, that sums up pretty nicely the world that emacs hails from.
Escape analysis to work out when heap allocations can be avoided, type inference to work out when dynamic type checks can be omitted / fixnum math can be used instead of generic math, when functions can be linked directly instead of dynamically dispatched, when functions are pure to allow for more flexible optimizations with evaluation order, etc.
Scheme adds even more complexity despite being a far smaller language than common lisp. Reified continuations massively complicate any optimzation and so does automatic lisp-1 to lisp-2 conversion, which has a bunch of caveats making it much trickier than it seems. Add on the fact that scheme lets you overwrite core primitive operations like car/cdr and there just isn't really any ground to stand on to prove anything about the code at all.
I have no idea how guile scheme runs as fast as it does.
GCC on the other hand is coming from a much better point of view: C is statically typed with full type signatures on every function, argument and variable, so you can safely eliminate all runtime type-checking and arity-checking. There's no garbage collection, so you don't need that. functions can't be redefined, and all must be declared before being used so you don't need a mechanism for dynamic dispatch, there's no closures so you don't need to perform any lambda lifting or closure conversion, you don't need the compiler or the interpreter available at runtime to handle calls to eval, loops are clearly marked and easy to optimize (vs lisp using tag-body and scheme using widespread recursion with TCO), fast iteration of lists in lisp requires the compiler to prove that it can safely eliminate a null check and C just doesn't do bounds checks, and so on.
There's an endless of list of reasons why it's easier to generate near-optimal assembly from C and why it's very hard to do so from lisp. A simple C compiler will produce far, far faster code than a simple lisp compiler.
Bash it's too bloated, it can even do TCP/IP. Netcat can do that; or even Gawk in that case.
On Unix philosophy and Lisp, Forth shares a lot of that with decomposiing tools into words instead functions and word chaining instead of pipes.
I used to feel the same, after using Linux and Vim for 15 years. But then I switched to Emacs 6 years ago; initially as an experiment, but I couldn’t go back to Vim after trying Org-mode and other packages.
Now my perspective has changed. Emacs at its core is not one program, in a sense. It is a Lisp interpreter with a GUI, that ships with thousands of ready-to-use Elisp programs that share common conventions for user interfaces, key bindings, extensions, and configuration. But you don’t run all those programs at once, only the ones you need, and the rest of the “bloat” is not used. So in that sense it does feel more like an operating system than a program, in a good way.
But Emacs itself is modular in a way similar to Unix. Just that instead of being modular in the sense of many executables exchanging text streams, it is modular in the sense of many Elisp programs passing lists or buffers around. The Unix philosophy implemented at another layer of abstraction, in a sense.
EDIT: Dired mentioned here is a good example: It is a file manager implemented as a separate "Elisp program" that communicates with coreutils under the hood.
But for sure, these days I prefer dired. I didn’t know about the permission thing, will have to try that out!
Huh? All your examples are easily done in a shell. GNU find and fd support regex, xargs can be used for bulk operations, etc. This is more flexible and scriptable than anything dired allows you to do. It might not be immediately easier, but once you grasp how a few basic shell utilities work and how to combine them, using shell history, functions, aliases, and key bindings becomes part of your muscle memory. This workflow is even more transferable across systems and environments.
I think dired is convenient if you're already using Emacs and want to do a quick operation, but the shell is far more generally useful in the long run.
As you say, none of them do anything that can't be done with find and xargs (and perhaps a little awk and sed), but they're occasionally handy for one-off operations.
I don't see how this is comparable to arbitrarily browsing through a directory, inspecting files, and manually marking the ones you want to act on. The feature I was describing is more akin to how we browse directories in a graphical desktop environment.
I use find, xargs, and similar tools as well, but they don't allow you to casually mark or unmark files and run operations on them later. With these tools, you need a fairly precise idea of what you're targeting. Then you have to write a glob or regex pattern up front, and then execute the command. That's a very different workflow from interactively exploring a directory, making ad-hoc decisions, and selectively marking files as you go.
You might be missing fzf from your toolbelt. Running `fzf --multi` does just that, and allows you to pipe the selection further to anything else you want to do.
This is why the shell is a more flexible environment. You don't need to adopt a large monolithic tool or drastically change your workflow to do something which you previously couldn't. You just need to insert another tool that does a single thing well into your existing pipelines, and your workflow can be improved with much less effort.
Shell tools, Unix utilities, and 'fzf --multi' are definitely very powerful. But at least to me, they don't seem to offer the same kind of spontaneous browsing and editing experience, I'm referring to.
To be clear, this isn't some sort of competition! I'm not claiming one approach is superior to the other. Every tool has its strengths. My comments highlighting the features of Emacs do not imply that other tools are inferior. Quite the contrary!
I'm very fond of computing and I enjoy having a broad set of excellent tools at my disposal. The only point I disagree with is the claim that "all your examples are easily done in a shell". In my experience, the kind of random, ad hoc browsing, previewing, editing, marking and unmarking files, I'm talking about isn't quite as straightforward in the shell. It's certainly possible, but it doesn't feel as seamless or fluid as it does in Emacs. But again, this is not a competition. This is just an acknowledgement that different tools do different things!
I regularly rely on commands like 'find ... -exec', 'xargs', 'fzf', etc. But I also use Dired (and Emacs, in general) extensively. I find familiarity with both styles of tools very useful and the knowledge of both types of tools are transferable across a wide range of systems and environments.
> In my experience, the kind of random, ad hoc browsing, previewing, editing, marking and unmarking files, I'm talking about isn't quite as straightforward in the shell. It's certainly possible, but it doesn't feel as seamless or fluid as it does in Emacs. But again, this is not a competition.
Certainly. We should all use the tools we feel most comfortable with. And, frankly, the kind of visual selection you mentioned is not something I frequently do myself. In the rare cases I've had to, I was fine with a more rudimentary approach of previewing the files in whatever program can read them and mapping them to filenames manually. Doing this with dired, fzf with preview mode, or in a proper file manager, whether that's in a terminal with something like lf or in a more featureful GUI one, would've probably been faster.
That said, I was also objecting to your original claim that this cannot be easily done with standard Unix tools. At the end of the day, the choice of tools and what is easier to accomplish is subjective. I personally don't like relying on a single tool for my workflows, so I use Emacs strictly for editing text files. I even prefer the Git CLI over Magit, which is pretty blasphemous in the Emacs world. :) And I really like composing small purpose-built tools in the shell, especially if I can repurpose them in some way I hadn't done before, so using the shell instead of a file manager feels more natural to me. But they're all preferences, and it would be silly to claim that one is objectively inferior or superior to another.
Cheers!
[1]: https://github.com/junegunn/fzf?tab=readme-ov-file#previewin...
It is not part of Dired but it is part of Emacs, so it works out of the box. For example, in plain vanilla Emacs, if we type C-o on a PDF file displayed in Dired, it opens up the PDF file in a split window using doc-view. Similarly, if I type C-o on a PNG file, it opens up the PNG file using image-mode in a split window. So you're right that this isn't part of Dired but it is part of Emacs, so all of this works out of the box in vanilla Emacs with zero customisations.
Dired can filter files with regexp; you can even fall back on GNU ‘find’ (‘find-dired’). And you can execute shell commands on filtered files in Dired (‘&’), it’s like xargs without the confusing syntax—but, of course, you can just run ‘xargs’ from it, if that’s what you prefer.
A graphical file-manager is, I find, a much nicer interface for file-management than the command-line. I see all filtered files, and I can view and edit them anytime, as I please. With the command-line, it’s like I’m working with blindfolds on.
Dired can be a nice refuge even if you’re a command-line junkie, because in-spite of its own commands (abstracting the shell), you can always drop back to the shell, as you please. Funnily enough, my usage of Dired vis-à-vis the shell is kind of the inverse of what you described, I use the shell for either quick or really complicated operations and Dired for everything else—which ends up being over 95% of my use.
Preference is definitely a factor, I agree with you there. But while a programming language is obviously more flexible technically, most people don't want to write a program to perform a task on their computer.
My point is that the shell is easier to script than writing Lisp (for most people; I'm sure Lisp nerds would disagree), and is more flexible than whatever facilities dired provides out of the box. To be fair, I haven't used dired more than a few times even though Emacs is my primary editor, but even if it emulates xargs or allows you to drop down to shell commands directly, it will never be as flexible for file operations as just using the shell.
The shell is not just a file manager. That's one of its primary features, sure, but it allows you to operate on files in an infinite number of ways. This is because it exposes fairly simple primitives that allow you to combine programs in ways that even their authors hadn't anticipated. This is why the do-one-thing-well philosophy is so powerful.
The famous Knuth-McIlroy story illustrates this well. Knuth created a sophisticated program to count words, which McIlroy replicated in a one-line shell script using a few UNIX tools. Knuth's was probably more correct, better documented, and handled edge cases better, but McIlroy's obviously required far less effort and would be easier to understand and expand. I don't think any tech geek or programmer would prefer writing a program for such relatively simple tasks.
My points were, first, Dired is easier than the shell for 99% of file management, as it’s a graphical file manager with many advanced functions. It’s literally a graphical ‘ls -l’ that that you can freely move around, browse and act on; the same way vi was a graphical ed. And, second,
> it will never be as flexible for file operations as just using the shell
for the remaining 1% where the shell would be easier than a Dired built-in, I’d rather do them from Dired, because, being a graphical program, I have a dynamic directory listing that I can peruse as I please. And the shell is the shell, whether you open a command-line in your terminal emulator or run shell commands from Dired.
Maybe the shell’s primitives are too abstract and I prefer them abstracted behind Dired. Emacs Lisp has primitive functions, too, it’s just the higher-level functions are useful most of the time.
> Knuth created a sophisticated program to count words, which McIlroy replicated in a one-line shell script using a few UNIX tools.
Yes, now let’s see McIlroy publish the C source of the Unix built-ins he used to be fair to Knuth in that comparison, who provided the whole source of his implementation.
Composibility was an afterthought when making C, and that’s what Unix inherits; redirecting text with pipes between different programs will never be as simple and elegant as an interface that was made for composibility and extension, from the programming language up—Lisp Machines. I have scarcely found shell one-liners to be elegant in the sense they make sense at first glance—granted I’m a user, not a programmer. Lisp functions—functional programming—on the other hand, when used together, have an intuitive flow, especially in how they modify input, that’s easy to wrap my head around.
But the word runs on Unix shell, much, much more so than a functional-programming-language REPLs—“worse is better” like you said earlier.
> I don't think any tech geek or programmer would prefer writing a program for such relatively simple tasks.
Writing little Emacs Lisp functions—combining more abstract built-in Emacs Lisp functions—feels a lot like chaining shell command together, but better.
Instead of typing up an entire command pipeline all at once, or running sections of the pipeline into temporary files that you examine/edit with a text editor, Emacs lets you run that same pipeline interactively in a text buffer (basically a temporary file). Being able to see the results as you work on it interactively is a huge advantage (compare ed vs vi).
This also works globally with #'find-file-at-point (which isn't bound to a hotkey by default, but should be: this is one of my most satisfying hotkeys. That function opens any filepath appearing as a string, in any context, in the working directory of that context—filepath strings in files, and filepath strings as outputs from shell commands, being the top two).
(It's like converting every file reference into a clickable URL—only, implicitly).
;; In dired mode, visit the file at the cursor in the right/below/left/above window.
(defun my-dired-display-direction ()
(interactive)
(let* ((file-or-dir (dired-get-file-for-visit)) ;; get the file at cursor
(buffer (find-file-noselect file-or-dir))) ;; load the file into a buffer
(let ((window ;; figure out the window to use
(cond ((get-buffer-window buffer (selected-frame)))
((window-in-direction 'right)) ;; try window in each direction
((window-in-direction 'below)) ;; and default to right
((window-in-direction 'left)) ;; if no window found.
((window-in-direction 'above))
(t (split-window (selected-window) nil 'right)))))
(window--display-buffer buffer window 'window nil)
window)) )
;; Bind ctrl-o to display at direction.
(define-key dired-mode-map (kbd "C-o") 'my-dired-display-direction)
In Vim, I use vinegar, which bind the minus key to display the file's directory in netrw and in netrw, go up.
I want the cursor/focus to remain on the dired window so that I can go down the file list and see the file content on the other window. Ctrl-n and ctrl-o are all I need to do.
1: https://www.gnu.org/software/emacs/manual/html_node/emacs/Wd...
Oil.nvim provides an incredible experience for managing files. It'll even use the LSP to fix imports if you move files from place to place.
paulyy_y•1mo ago
snapdaddy•1mo ago
bigdict•1mo ago
hollerith•1mo ago
internet_points•1mo ago
tadfisher•1mo ago
rbc•1mo ago
hollerith•1mo ago
The web of the early 1990s could be called the same thing, but not the modern web, which is more like a "generalized experience-delivery platform with an old much-simpler generalized interface to information at its core".
TacticalCoder•1mo ago
timewizard•1mo ago