This extension displays file and folder icons in dired mode. It uses mimetype as the displayed logo and follows the icon-theme-spec file naming convention, so you can use icon themes downloaded from the internet in your emacs.

In the code, I defined a minor mode called dired-mimeicon-mode. It displays icons for file types in a Dired buffer. The icons are overlays on top of the filenames. They are loaded from an icon theme directory specified by dired-mimeicon-root-dir and dired-mimeicon-name, and displayed as SVG images at 26x26 pixels. The icon for a file is picked from its MIME type using the mailcap library. If the MIME type is not recognized, or the icon file is missing, it falls back to a default icon.
The code defines several functions:
- dired-mimeicon-overlays-in: Returns a list of overlays in the specified region that have the dired-mimeicon-overlay property set.
- dired-mimeicon-clear-overlays: Removes all overlays with the dired-mimeicon-overlay property in the buffer.
- dired-mimeicon-insert-icon-to-overlay: Adds an icon overlay for a file at the specified position in the buffer.
- dired-mimeicon-refresh: Refreshes the icons in the buffer by clearing existing overlays and creating new ones for each file in the buffer.
- dired-mimeicon-refresh-advice: An advice function that calls dired-mimeicon-refresh after certain Dired functions are called.
- dired-mimeicon-enable: Enables the dired-mimeicon-mode minor mode by adding advice to Dired functions and calling dired-mimeicon-refresh.
- dired-mimeicon-disable: Disables the dired-mimeicon-mode minor mode by removing advice from Dired functions and clearing icon overlays.
- dired-mimeicon-mode: The dired-mimeicon-mode minor mode itself. When enabled, it calls dired-mimeicon-enable. When disabled, it calls dired-mimeicon-disable.
Installation
- Clone the repository to your emacs extension directory
- Add the following code to your ~/.emacs
(require 'dired-mimeicon)
(add-hook 'dired-mode-hook 'dired-mimeicon-mode)