emacs_dired_set_faces

This is part of The Pile, a partial archive of some open source mailing lists and newsgroups.



From: Jean-Philippe Theberge <jphil@godzilla.act.oda.fr>
Subject: Re: dired-mode
Date: 26 Jun 2000 15:39:55 +0200

Javier Oviedo <joviedo@rac10.wam.umd.edu> writes:

> Hey:
> 
> 	Are there special faces for dired mode? I want to add a hook to
> change the appearance of things in dired-mode but I'm not sure what faces
> are supported by dired mode. For example, I want directories to be one
> color, executables to be another..and so on. Is this possible? Thanks.

I have this on my .emacs to do just that.
The code is not from me but I can't remember where I took it from.


(eval-after-load "dired"
  '(progn
     ;; (defun my-dired-move-to-filename (&optional raise-error eol)
     ;;   (or eol (setq eol (progn (end-of-line) (point))))
     ;;   (beginning-of-line)
     ;;   (forward-char 57)
     ;;   (if (and (> (point) eol) raise-error)
     ;;       (error "No file on this line")))

     ;; (defun my-dired-move-to-date (&optional raise-error eol)
     ;;   (or eol (setq eol (progn (end-of-line) (point))))
     ;;   (beginning-of-line)
     ;;   (forward-char 44)
     ;;   (if (and (> (point) eol) raise-error)
     ;;       (error "No file on this line")))

     (defun my-dired-move-to-date (&optional raise-error eol)
       (dired-move-to-filename raise-error eol)
       (backward-char 13))

     ;; (defun my-dired-move-to-size (&optional raise-error eol)
     ;;   (or eol (setq eol (progn (end-of-line) (point))))
     ;;   (beginning-of-line)
     ;;   (forward-char 31)
     ;;   (if (and (> (point) eol) raise-error)
     ;;       (error "No file on this line")))

     (defun my-dired-move-to-size (&optional raise-error eol)
       (dired-move-to-filename raise-error eol)
       (backward-char 25))



     (setq dired-font-lock-keywords
           (list
            ;; Size
            '("^. -"
              (" *\\([0-9]+\\).*" (my-dired-move-to-size) nil
               (1 font-lock-string-face)))
            ;; Date
            '("^. [-dlcbs]"
              ("\\(............\\).*" (my-dired-move-to-date) nil
               (1 font-lock-keyword-face)))
            ;; Omitted files
            '(" [#.][^.].*$"            ; obtained from dired-omit-files
              ("[#.][^.].*" (dired-move-to-filename) nil
               (0 font-lock-builtin-face)))
            ;; Directories
            '("^. d"
              (0 font-lock-function-name-face)
              (" *\\([0-9]+\\).*" (my-dired-move-to-size) nil
               (1 font-lock-function-name-face))
              (".+" (dired-move-to-filename) nil
               (0 font-lock-function-name-face))
              )
            ;; Symbolic links
            (list dired-re-sym          ; "^. [0-9 \t]*l"
                  '(0 font-lock-constant-face)
                  '(".+" (dired-move-to-filename) nil
                    (0 font-lock-constant-face)))
            ;; Backup and autosave files
            '("[~%#]$"
              (".+" (dired-move-to-filename) nil (0 font-lock-comment-face)))
	    '("\\.\\(bak\\)$"               
	      (".+" (dired-move-to-filename) nil
               (0 font-lock-comment-face)))
            ;; program files (source codes, any languages)
            '("\\.\\(el\\|p[ml]\\|cgi\\)$"
              (".+" (dired-move-to-filename) nil
               (0 font-lock-variable-name-face)))
            ;; Zipped files
            '("\\.\\(gz\\|tgz\\|bz2\\|Z\\|zip\\)$"
              (".+" (dired-move-to-filename) nil (0 font-lock-type-face)))
            ;; World permissions
            ;;'("^..[d-]......\\(r..\\|.w.\\|..[xs]\\) " 1 font-lock-type-face)
            ;; Write permissions
            '("^. [d-]....\\(w\\)" 1 font-lock-type-face)
            '("^. [d-]......\\(.w.\\)" 1 font-lock-type-face)
            ;; Directory name
            (list dired-subdir-regexp   ; "^. \\([^\n]+\\)\\(:\\)[\n]"
                  '(1 font-lock-function-name-face)
                  '(1 'bold append))
            ;; Marked for deletion
            '("^D"
              (0 font-lock-warning-face prepend)
              (".+" (dired-move-to-filename) nil
               (0 font-lock-warning-face prepend))
              (".+" (beginning-of-line) nil (0 'bold prepend)))
            ;; Marked (not for deletion)
            '("^[^ D\n]"
              (0 font-lock-warning-face prepend)
              (".+" (beginning-of-line) nil (0 'bold prepend)))))))


-jp

Path: nntp.stanford.edu!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!cpk-news-hub1.bbnplanet.com!washdc3-snh1.gtei.net!news.gtei.net!dfiatx1-snr1.gtei.net.POSTED!not-for-mail

===

Subject: Re: dired-mode
From: Jim Davidson <jdavidson@nospam.com>
Date: Tue, 04 Jul 2000 18:07:22 GMT

Javier Oviedo <joviedo@rac10.wam.umd.edu> writes:

> Hey:
> 
> 	Are there special faces for dired mode? I want to add a hook to
> change the appearance of things in dired-mode but I'm not sure what faces
> are supported by dired mode. For example, I want directories to be one
> color, executables to be another..and so on. Is this possible? Thanks.

You don't say which version of Emacs you're running, but in 20.7 dired
includes all this.  Check the settings for dired-font-lock-keywords
in dired.el.

If you have font-lock turned on, you should see colors for things like 
sub-directories, backup files, marked files....

-- 
Jim Davidson
jdavidson @ acm.org


the rest of The Pile (a partial mailing list archive)

doom@kzsu.stanford.edu