reddit / emacs

All files in one directory: How do you manage that?

TiMueller · 2022-10-21 06:09
I read somewhere that it would be best in Emacs to put all files into a single directory. Does anyone of you do that? How do you find the file you currently need? Is there a way to tag the files, so that Dired can show all invoices, for instance? I currently still have different directories, and have defined the keys 1-7 in dired-mode-map to open them. But of course it would be nice to just enter the first letters of the file name in Helm Mini in the case that I know the file name, which currently only works for recent files and for files in my Org directory.
danderzei · 2022-10-21 08:26
Sub-directories are a effectively a method to attach metadata to a file. In other words, the name of the folder provides information about the category of files contained within it. Another method is storing everything in one folder. This means that you either store metadata in the filename (e.g. the Denote package) or you store metadata externally in a database or other file (e.g. Org Roam). There is no single best way in Emacs. The best method is whatever suits your workflow best. Whatever you do, a clear naming convention for your files is essential to ever find anything back. However, software such as the Silver Searcher provide convenient ways to search inside all your files.
NDcodes · 2022-10-21 13:22
What is the value provided by placing all files in one directory? I’m guessing people are doing it to make it faster to navigate to specific files and open them? But if you have a decent completion-framework, you can be pretty fast at navigating through directories in the minibuffer. And there’s ways you can “pin” or bookmark specific files/projects (for example using treemacs for projects or bookmarks to save specific files and locations). You can also use recentf to view a list of recently opened files. In other words, I think there’s plenty of ways to “speed up” the opening of specific files (your strategy for dired-mode-map is also a great one). Given that, I really don’t think it’d be worth it to sacrifice organization by placing all files in one folder. I fail to see the advantage of that.
TiMueller · 2022-10-21 18:08
Thank you very much for your good advice! I am right now looking at Denote, it has a very good manual. Will find out all about Silver Searcher afterwards. But what is also precious for me is your thought about a clear naming convention, even outside of a package. Thanks again!
takeonrules · 2022-10-22 04:08
Have you looked at Denote? http://protesilaos.com/emacs/denote It provides a keywords mechanism.
[deleted] · 2022-10-22 06:03
I'm guessing you aren't putting invoices in the same directory as .c files... Check out [Deft](https://jblevins.org/projects/deft/).
meedstrom · 2022-10-22 15:55
I thought you meant *all* files, but from other answers here, it sounds like you just mean Org files and some related cruft? Tip: you can still find any nested file with `helm-locate`, `counsel-file-jump` or similar. Or if you prefer working in Dired, you can use `dired-insert-subdir` on all subdirectories to get a giant listing. But what if we really put all non-system files into a single directory? - Symlink XDG directories like Pictures, Downloads back into the user home `~` - Treat `~` as an immutable store, like a miniature IPFS: never delete anything - Never name a new file, have files auto-named by date and time (but possibly prompt user for a tag) - Allow directories where it's naturally enforced, like git repos, or for performance reasons, like org-roam - Lots of programs generally ask you for a folder, think of it as like they're asking for a tag to filter for... But you don't need a hierarchy more than one level deep - Occasionally delete large files by searching for them with `ncdu` or `baobab` The main problem is we lack tooling for working this way, so it has to be homebrew. You can go far by combining tricks like wdired + multiple-cursors to rename files en masse, but we still need hooks for renaming new files as they come in, and commands for searching and narrowing a dired buffer, and probably deal with lots of edge cases. I suspect it's more work in the long run. The golden middle is to have a bit of a directory structure, but just a bit. I keep all the files I care about (and may want to back up) in `/home/kept`, with a subdir for my .emacs.d, one for code repos, one for dotfiles (`/home/kept/dotfiles/*` have symlinks in `~/`), one for org files, one for life photos, one for music, one for archived stuff I no longer want cluttering up my sight, and one called "never-sorted" for random things, which I occasionally tarball up and shove into the archive with a datestamp.
TiMueller · 2022-10-23 07:29
This is very helpful and interesting, thank you so much, also for sharing your directory structure. And I completely forgot about helm-locate! Maybe that could be the solution for me already. I write novels and small books with essays for a living, and until I started using Emacs last year, I had a subfolder for every one of my 30 books, also a folder for invoices, a folder for letters, a folder for my website, a folder for talks I am giving and a folder for smaller articles I write. Now I am getting addicted to the one keystroke for opening Helm-Minis and just entering the first three letters of a filename for opening it. So much that I already feel a bit annoyed when I need to open a file that is nested somewhere deeper and need to use Dired and switch a few directories first. And I am step by step moving all my usecases to Emacs, writing invoices and letters with it now before exporting them to PDF and printing them, maintaining my website with it, of course structuring the material for my books with Org mode and writing a whole novel for the first time in Emacs right now. So I was wondering how longtime Emacs users do it, how they use directories or how they remember enough of their filenames to be able to open them in Helm just by entering a few letters. Org-Contacts for instance helps me remember names in an interesting way: I save a tag for every contact, and when I let Helm show me the conctact list for choosing an email, the tags are shown too, and I can enter a tag to narrow down the list. If I just remember it was someone of the publishing house in the marketing department, but don't remember the name, I enter the tag "verlag" (German for "publisher"), and the list shows only the contacts of that category. I was wondering if someone had all textfiles in one directory and somehow tagged them in this way. And I learned a lot from all your answers already: I could name files in a way that the filename is used as a tag, or "tag" them by putting them in appropriate subdirectories and use helm-locate or Deft. What a great community here!
TiMueller · 2022-10-23 07:31
No, just textfiles of some sort: letters, invoices, book concepts, the html source for my website. Deft ist a great idea, thank you!
TiMueller · 2022-10-23 07:31
Very good, thanks a lot!