I'm sure some of you reading this are rolling your eyes or reciting the well-known "Emacs is a great OS, but …" I use it a lot, though. I already use dired-mode to manage my writing and programming. It's something that is powerful, and comfortable to use. If you are following along and use something else, it is also quite easy to adjust my code here as well. Ok, with that out of the way let's look at what we actually want to do: xdg-mime needs to connect "Opening a directory" with "opening emacs in dired-mode." First, we need the MIME type for directories. A quick search shows that it is called inode/directory. I have no idea why it is called inode/directory, and I couldn't find an explanation. I've learned not to ask questions about these names. Opening emacs in dired-mode is the easy part: if you pass emacs a directory instead of a file, it automatically opens in the appropriate mode. Great! Now we need to tie these two concepts together. If we were using a non-declarative system, such as Debian, I would suggest doing something like creating a .desktop file, running xdg-mime default emacs-dired.desktop inode/directory and that would be it. You could theoretically do this on Guix as well. There is a big downside with this strategy, though: the changes you make are not documented anywhere on your system. If you wanted to duplicate your setup on a new laptop, for example, you would have to either note down this change you made or run into it again, hopefully remember your solution, and then reproduce it. Maybe this works for others, but I know myself. I will not remember, I will run into it again, and then I will get frustrated again. That's why we have guix-home configuration. home-xdg-mime-applications-service-type is a very helpful service in the guix-home configuration tool. It allows you to create xdg-desktop-entry for each .desktop file you would normally need to create, link those to the MIME type of your choice, and that's it. It is also all written down expl...
First seen: 2025-05-23 20:31
Last seen: 2025-05-24 00:32