From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Fabian Braennstroem Newsgroups: gmane.emacs.help Subject: Re: some dired questions Date: Wed, 13 Jun 2007 20:34:05 +0000 Organization: FernUni Hagen Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1181763637 30476 80.91.229.12 (13 Jun 2007 19:40:37 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 13 Jun 2007 19:40:37 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Jun 13 21:40:36 2007 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 1HyYhm-0000rx-Bd for geh-help-gnu-emacs@m.gmane.org; Wed, 13 Jun 2007 21:40:34 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HyYhj-0007vf-L1 for geh-help-gnu-emacs@m.gmane.org; Wed, 13 Jun 2007 15:40:31 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!news-fra1.dfn.de!news-koe1.dfn.de!tamarack.fernuni-hagen.de!news.fernuni-hagen.de!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 132 Original-NNTP-Posting-Host: pd9e48ddf.dip0.t-ipconnect.de Original-X-Trace: tamarack.fernuni-hagen.de 1181759216 1992 217.228.141.223 (13 Jun 2007 18:26:56 GMT) Original-X-Complaints-To: newsadmin@fernuni-hagen.de Original-NNTP-Posting-Date: Wed, 13 Jun 2007 18:26:56 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:1.8.1.3) Gecko/20070326 Thunderbird/2.0.0.0 Mnenhy/0.7.5.0 In-Reply-To: Original-Xref: shelby.stanford.edu gnu.emacs.help:149434 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:45022 Archived-At: Hi William, it works nice! Thanks! William Xu schrieb am 06/13/2007 04:35 AM: > Fabian Braennstroem writes: > > I was looking for a way to adjust dired's coloring to the terminal > colors provided > by '.dircolors'. I saw 'dircolors.el', but it does not seem to be > helpful for dired's mode!? > > You can modify `dired-font-lock-keywords'. Try my setup: > > ;; apply shell's color scheme to dired > ;; ----------------------------------- > > (setq xwl-dircolors-string > (replace-regexp-in-string > ":$" "" (cadr > (split-string > (shell-command-to-string "dircolors") > "'")))) > > ;; colored by file extensions > (setq xwl-dircolors-extensions > (split-string > (replace-regexp-in-string > "=[0-9;]+\\|\\*\\." "" > (replace-regexp-in-string "^[^*]*" "" xwl-dircolors-string)) > ":")) > > (defun xwl-dircolors-get-escape-seq (regexp) > "Get escape-seq by matching REGEXP against `xwl-dircolors-string'. > e.g., (xwl-dircolors-get-escape-seq \"*.gz\") => \"01;31\"" > (string-match (concat regexp "=\\([^:]+\\):") xwl-dircolors-string) > (match-string 1 xwl-dircolors-string)) > > (setq dired-font-lock-keywords > `( > ;; > ;; Directory headers. > ,(list dired-subdir-regexp '(1 dired-header-face)) > ;; > ;; Dired marks. > ,(list dired-re-mark '(0 dired-mark-face)) > ;; > ;; We make heavy use of MATCH-ANCHORED, since the regexps don't identify the > ;; file name itself. We search for Dired defined regexps, and then use the > ;; Dired defined function `dired-move-to-filename' before searching for the > ;; simple regexp ".+". It is that regexp which matches the file name. > ;; > ;; Marked files. > ,(list (concat "^[" (char-to-string dired-marker-char) "]") > '(".+" (dired-move-to-filename) nil (0 dired-marked-face))) > ;; > ;; Flagged files. > ,(list (concat "^[" (char-to-string dired-del-marker) "]") > '(".+" (dired-move-to-filename) nil (0 dired-flagged-face))) > ;; People who are paranoid about security would consider this more > ;; important than other things such as whether it is a directory. > ;; But we don't want to encourage paranoia, so our default > ;; should be what's most useful for non-paranoids. -- rms. > ;;; ;; > ;;; ;; Files that are group or world writable. > ;;; (list (concat dired-re-maybe-mark dired-re-inode-size > ;;; "\\([-d]\\(....w....\\|.......w.\\)\\)") > ;;; '(1 dired-warning-face) > ;;; '(".+" (dired-move-to-filename) nil (0 dired-warning-face))) > ;; However, we don't need to highlight the file name, only the > ;; permissions, to win generally. -- fx. > ;; Fixme: we could also put text properties on the permission > ;; fields with keymaps to frob the permissions, somewhat a la XEmacs. > ,(list (concat dired-re-maybe-mark dired-re-inode-size > "[-d]....\\(w\\)....") ; group writable > '(1 dired-warning-face)) > ,(list (concat dired-re-maybe-mark dired-re-inode-size > "[-d].......\\(w\\).") ; world writable > '(1 dired-warning-face)) > ;; > ;; Subdirectories. > ,(list dired-re-dir > '(".+" (dired-move-to-filename) nil (0 dired-directory-face))) > ;; > ;; Symbolic links. > ,(list dired-re-sym > '(".+" (dired-move-to-filename) nil (0 dired-symlink-face))) > > ;; executables > ,(list dired-re-exe > `(".+" > (dired-move-to-filename) > nil > (0 (ansi-color-get-face ,(xwl-dircolors-get-escape-seq "ex"))))) > > ;; colorful by extensions > ,@(mapcar (lambda (ext) > `(,(format ".*\\.%s$" ext) > (".+" > (dired-move-to-filename) > nil > (0 (ansi-color-get-face ,(xwl-dircolors-get-escape-seq ext)))))) > xwl-dircolors-extensions) > > ;; > ;; 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)))) > ;; > ;; Files suffixed with `completion-ignored-extensions' > ;; plus a character put in by -F. > (eval . > (list (concat "\\(" (regexp-opt completion-ignored-extensions) > "\\|#\\)[*=|]$") > '(".+" (progn > (end-of-line) > ;; If the last character is not part of the filename, > ;; move back to the start of the filename > ;; so it can be fontified. > ;; Otherwise, leave point at the end of the line; > ;; that way, nothing is fontified. > (unless (get-text-property (1- (point)) 'mouse-face) > (dired-move-to-filename))) > nil (0 dired-ignored-face)))))) > > Regards! Fabian