* Customize face according to extension
@ 2008-05-27 14:59 henry atting
2008-05-28 3:33 ` Kevin Rodgers
0 siblings, 1 reply; 4+ messages in thread
From: henry atting @ 2008-05-27 14:59 UTC (permalink / raw)
To: help-gnu-emacs
Hi,
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.
Cheers,
henry
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Customize face according to extension
2008-05-27 14:59 Customize face according to extension henry atting
@ 2008-05-28 3:33 ` Kevin Rodgers
2008-05-29 6:57 ` Kevin Rodgers
[not found] ` <mailman.12370.1212044415.18990.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 4+ messages in thread
From: Kevin Rodgers @ 2008-05-28 3:33 UTC (permalink / raw)
To: help-gnu-emacs
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\\'".
--
Kevin Rodgers
Denver, Colorado, USA
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Customize face according to extension
2008-05-28 3:33 ` Kevin Rodgers
@ 2008-05-29 6:57 ` Kevin Rodgers
[not found] ` <mailman.12370.1212044415.18990.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 4+ messages in thread
From: Kevin Rodgers @ 2008-05-29 6:57 UTC (permalink / raw)
To: help-gnu-emacs
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Customize face according to extension
[not found] ` <mailman.12370.1212044415.18990.help-gnu-emacs@gnu.org>
@ 2008-05-30 13:30 ` henry atting
0 siblings, 0 replies; 4+ messages in thread
From: henry atting @ 2008-05-30 13:30 UTC (permalink / raw)
To: help-gnu-emacs
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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-05-30 13:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-27 14:59 Customize face according to extension henry atting
2008-05-28 3:33 ` Kevin Rodgers
2008-05-29 6:57 ` Kevin Rodgers
[not found] ` <mailman.12370.1212044415.18990.help-gnu-emacs@gnu.org>
2008-05-30 13:30 ` henry atting
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.