[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master bdc1f19: dired: Show broken/circular links w/ different face
From: |
Tino Calancha |
Subject: |
master bdc1f19: dired: Show broken/circular links w/ different face |
Date: |
Thu, 27 Aug 2020 05:53:22 -0400 (EDT) |
branch: master
commit bdc1f193470633adcd860db4b05a9fe951bd375b
Author: Tino Calancha <tino.calancha@gmail.com>
Commit: Tino Calancha <tino.calancha@gmail.com>
dired: Show broken/circular links w/ different face
* lisp/dired.el (dired-broken-symlink): New face.
(dired-font-lock-keywords):
Use it for broken/circular links (Bug#39145).
* etc/NEWS (Changes in Specialized Modes and Packages in Emacs 28.1):
Announce this change.
---
etc/NEWS | 4 ++++
lisp/dired.el | 22 ++++++++++++++++++++++
2 files changed, 26 insertions(+)
diff --git a/etc/NEWS b/etc/NEWS
index 6e04a1c..8b9bd07 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -240,6 +240,10 @@ time zones will use a form like "+0100" instead of "CET".
** Dired
+---
+*** Broken and circular links are shown with the new
+ 'dired-broken-symlink' face.
+
*** '=' ('dired-diff') will now put all backup files into the 'M-n' history.
When using '=' on a file with backup files, the default file to use
for diffing is the newest backup file. You can now use 'M-n' to quickly
diff --git a/lisp/dired.el b/lisp/dired.el
index 08d0468..d122869 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -534,6 +534,14 @@ Subexpression 2 must end right before the \\n.")
(defvar dired-symlink-face 'dired-symlink
"Face name used for symbolic links.")
+(defface dired-broken-symlink
+ '((((class color))
+ :foreground "yellow1" :background "red1" :weight bold)
+ (t :weight bold :slant italic :underline t))
+ "Face used for broken symbolic links."
+ :group 'dired-faces
+ :version "28.1")
+
(defface dired-special
'((t (:inherit font-lock-variable-name-face)))
"Face used for sockets, pipes, block devices and char devices."
@@ -597,6 +605,20 @@ Subexpression 2 must end right before the \\n.")
(list dired-re-dir
'(".+" (dired-move-to-filename) nil (0 dired-directory-face)))
;;
+ ;; Broken Symbolic link.
+ (list dired-re-sym
+ (list (lambda (end)
+ (let* ((file (dired-file-name-at-point))
+ (truename (ignore-errors (file-truename file))))
+ ;; either not existent target or circular link
+ (and (not (and truename (file-exists-p truename)))
+ (search-forward-regexp "\\(.+\\) \\(->\\) ?\\(.+\\)"
end t))))
+ '(dired-move-to-filename)
+ nil
+ '(1 'dired-broken-symlink)
+ '(2 dired-symlink-face)
+ '(3 'dired-broken-symlink)))
+ ;;
;; Symbolic link to a directory.
(list dired-re-sym
(list (lambda (end)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master bdc1f19: dired: Show broken/circular links w/ different face,
Tino Calancha <=