help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: icons for filetype in dired


From: Juri Linkov
Subject: Re: icons for filetype in dired
Date: Sun, 25 Nov 2007 23:35:39 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.50 (gnu/linux)

> is there a chance to get icons into each line in a dired
> buffer according to the filetype. Something like
> http://www.netlaputa.ne.jp/~kose/Emacs/iimage.html ,but with
> small icons!?
> If it is not too slow, it would be realy helpful :-)

(defun dired-insert-file-icons ()
  "Insert icons before file names in the dired buffer."
  (interactive)
  (dired-map-dired-file-lines
   (lambda (file)
     (let* ((image-pos (dired-move-to-filename))
            (mime-type (mailcap-extension-to-mime (file-name-extension file t)))
            (icon-file
             (if mime-type (concat 
"/usr/share/icons/kdeclassic/16x16/mimetypes/"
                                   mime-type)))
            overlay)
       (unless (and icon-file (file-exists-p icon-file))
         ;; default icon
         (setq icon-file 
"/usr/share/icons/kdeclassic/16x16/mimetypes/empty.png"))
       (unless (delq nil (mapcar (lambda (o) (overlay-get o 'put-image))
                                 (overlays-in (point) (1+ (point)))))
         (put-image (create-image icon-file) image-pos)
         (setq overlay
               (car (delq nil (mapcar (lambda (o) (and (overlay-get o 
'put-image) o))
                                      (overlays-in (point) (1+ (point)))))))
         (overlay-put overlay 'file file)
         (overlay-put overlay 'icon-file icon-file))))))

(add-hook 'dired-after-readin-hook 'dired-insert-file-icons)

-- 
Juri Linkov
http://www.jurta.org/emacs/


reply via email to

[Prev in Thread] Current Thread [Next in Thread]