bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#17064: 24.3.50; Enhancement request: dired: fontification of symlink


From: Michael Heerdegen
Subject: bug#17064: 24.3.50; Enhancement request: dired: fontification of symlinks
Date: Sat, 22 Mar 2014 00:34:01 +0100

Hi,

in dired, symlinks look like

  symlink -> target

where the whole thing is fontified with dired-symlink-face.  But I
already know from the -> that I have a symlink, it would be more useful
to know whether TARGET is a directory, which is what I normally see for
non symlink files in dired by fontification with dired-directory-face.

My proposal: fontify only the first part "symlink ->" with
dired-symlink-face.  Fontify "target" according to its truename type.

I'm no expert for font lock, so I don't send a patch but just post the
code I use in my config:

--8<---------------cut here---------------start------------->8---
(cl-callf2 cl-remove dired-re-sym dired-font-lock-keywords :key #'car)

(cl-callf nconc dired-font-lock-keywords
  `((,dired-re-sym
     ((lambda (end) (when (let ((file (dired-file-name-at-point)))
                       (file-directory-p (file-truename file)))
                 (search-forward-regexp "\\(.+-> ?\\)\\(.+\\)" end t)))
      (dired-move-to-filename)
      nil
      (1 dired-symlink-face)
      (2 dired-directory-face)))
    (,dired-re-sym
     ((lambda (end) (when (let ((file (dired-file-name-at-point)))
                       (file-regular-p (file-truename file)))
                 (search-forward-regexp "\\(.+-> ?\\)\\(.+\\)" end t)))
      (dired-move-to-filename)
      nil
      (1 dired-symlink-face)
      (2 'default)))))
--8<---------------cut here---------------end--------------->8---

Or could this have any bad side effects?  Is it maybe too heavy to call
`file-truename'?


Thanks,

Michael.



In GNU Emacs 24.3.50.2 (x86_64-unknown-linux-gnu, GTK+ Version 3.10.7)
 of 2014-03-14 on drachen
Windowing system distributor `The X.Org Foundation', version 11.0.11500000
System Description:     Debian GNU/Linux testing (jessie)

Important settings:
  value of $LC_ALL: de_DE.utf8
  value of $LC_COLLATE: C
  value of $LC_TIME: C
  value of $LANG: de_DE.utf8
  locale-coding-system: utf-8-unix

Major mode: Emacs-Lisp






reply via email to

[Prev in Thread] Current Thread [Next in Thread]