* some dired questions
@ 2007-06-12 21:22 Fabian Braennstroem
2007-06-13 4:35 ` William Xu
[not found] ` <mailman.2074.1181710035.32220.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 3+ messages in thread
From: Fabian Braennstroem @ 2007-06-12 21:22 UTC (permalink / raw)
To: help-gnu-emacs
Hi,
I have some small questions about dired...
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!?
How can I run a function on a the currently highlighted file, e.g.
I would like to tail a log file using "tail.el"?
The 'tail-file' waits for a filename in the mini-buffer, but it
would be nice, if it takes the actual file in dired...
I know, that I run special shell commands on the current file using
'!', it works pretty nice for different programs,
but for a certain batch job I need to call: 'PROGRAM_NAME <
CURRENT_FILE > CURRENT_FILE.log'!?
Maybe, some of you a an idea!? Would be great!
Regards!
Fabian
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: some dired questions
2007-06-12 21:22 some dired questions Fabian Braennstroem
@ 2007-06-13 4:35 ` William Xu
[not found] ` <mailman.2074.1181710035.32220.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 3+ messages in thread
From: William Xu @ 2007-06-13 4:35 UTC (permalink / raw)
To: help-gnu-emacs
Fabian Braennstroem <f.braennstroem@gmx.de> 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))))))
--
William
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: some dired questions
[not found] ` <mailman.2074.1181710035.32220.help-gnu-emacs@gnu.org>
@ 2007-06-13 20:34 ` Fabian Braennstroem
0 siblings, 0 replies; 3+ messages in thread
From: Fabian Braennstroem @ 2007-06-13 20:34 UTC (permalink / raw)
To: help-gnu-emacs
Hi William,
it works nice! Thanks!
William Xu schrieb am 06/13/2007 04:35 AM:
> Fabian Braennstroem <f.braennstroem@gmx.de> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-06-13 20:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-12 21:22 some dired questions Fabian Braennstroem
2007-06-13 4:35 ` William Xu
[not found] ` <mailman.2074.1181710035.32220.help-gnu-emacs@gnu.org>
2007-06-13 20:34 ` Fabian Braennstroem
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).