[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Customize face according to extension
From: |
henry atting |
Subject: |
Re: Customize face according to extension |
Date: |
Fri, 30 May 2008 15:30:15 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) |
Kevin Rodgers wrote:
> 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)))))
Great. Yes, that works fine. I had a sort of solution of my own -- which
didn't work (and was inelegant anyway)
Then your code didn't work either -- which could not be ;)
If found out it was simply that the above settings were overwritten by
'dired+'. I adjusted it so that dired+ understands it too, and added
these lines additionally:
(defface diredp-display-nry '((t (:inherit secondary-selection)))
"*Face used for files with \".nry\" extension."
:group 'Dired-Plus)
(defvar diredp-display-nry 'diredp-display-nry)
(add-to-list 'diredp-font-lock-keywords-1
;; see dired-ignored-face entry:
'(eval .
(list "\\.nry$"
'(".+" (dired-move-to-filename) nil (0 diredp-display-nry)))))
Thanks,
henry