From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: henry atting Newsgroups: gmane.emacs.help Subject: Re: Customize face according to extension Date: Fri, 30 May 2008 15:30:15 +0200 Organization: LiteraturLateNight Message-ID: <87prr3c42g.fsf@literaturlatenight.de> References: <871w3nyerk.fsf@literaturlatenight.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1212181901 19265 80.91.229.12 (30 May 2008 21:11:41 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 30 May 2008 21:11:41 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri May 30 23:12:22 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1K2Btd-0001ME-Sz for geh-help-gnu-emacs@m.gmane.org; Fri, 30 May 2008 23:12:22 +0200 Original-Received: from localhost ([127.0.0.1]:35131 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K2Bsr-00077r-Vg for geh-help-gnu-emacs@m.gmane.org; Fri, 30 May 2008 17:11:34 -0400 Original-Path: news.stanford.edu!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!news-fra1.dfn.de!news-stu1.dfn.de!news.uni-stuttgart.de!rz.uni-karlsruhe.de!feed.news.schlund.de!schlund.de!news.online.de!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 60 Original-NNTP-Posting-Host: port-92-195-24-85.dynamic.qsc.de Original-X-Trace: online.de 1212154215 4577 92.195.24.85 (30 May 2008 13:30:15 GMT) Original-X-Complaints-To: abuse@einsundeins.com Original-NNTP-Posting-Date: Fri, 30 May 2008 13:30:15 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) Cancel-Lock: sha1:JvWyxK6tJ/zJR3Uiv6JLxqCNe+s= Original-Xref: news.stanford.edu gnu.emacs.help:159003 X-Mailman-Approved-At: Fri, 30 May 2008 17:09:59 -0400 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:54371 Archived-At: 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