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

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

Re: Customize face according to extension


From: Kevin Rodgers
Subject: Re: Customize face according to extension
Date: Thu, 29 May 2008 00:57:22 -0600
User-agent: Thunderbird 2.0.0.14 (Macintosh/20080421)

Kevin Rodgers wrote:
henry atting wrote:
how can I customize the face of a file according to a certain suffix?
Let's say the extension is *.nry, now I want to see all files with that
extension listed in a specific colour in eshell or dired.

Check out this entry in dired-font-lock-keywords:

   ;; Files suffixed with `completion-ignored-extensions'.
   '(eval .
     ;; It is quicker to first find just an extension, then go back to the
;; start of that file name. So we do this complex MATCH-ANCHORED form. (list (concat "\\(" (regexp-opt completion-ignored-extensions) "\\|#\\)$")
       '(".+" (dired-move-to-filename) nil (0 dired-ignored-face))))


That suggests you could define a new face and add a similar entry to
dired-font-lock-keywords that references it instead of
dired-ignored-face, for the simple regexp "\\.nry\\'".

This seems to work:

(require 'dired)

(defface dired-nry '((t (:inherit secondary-selection)))
  "Face used for files with \".nry\" extension.")

(defvar dired-nry-face 'dired-nry
  "Face used for files with \".nry\" extension.")

(add-to-list 'dired-font-lock-keywords
             ;; see dired-ignored-face entry:
             '(eval .
                    (list "\\.nry$"
                          '(".+" (dired-move-to-filename) nil (0 
dired-nry-face)))))

--
Kevin Rodgers
Denver, Colorado, USA





reply via email to

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