summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortrungtq <taquangtrungvn@gmail.com>2021-09-13 15:53:36 +0800
committertrungtq <taquangtrungvn@gmail.com>2021-09-13 15:53:36 +0800
commit361b2a0d245992a8643f0e0b20f833a50e917ea1 (patch)
treec873e6ff9cba038050c24554d189f0c45ddc3d22
parentc0919981511fceb0bd10d566794984b8031e8dfd (diff)
highlight file extension in buffer names
-rw-r--r--helm-buffers.el15
1 files changed, 12 insertions, 3 deletions
diff --git a/helm-buffers.el b/helm-buffers.el
index 05a75d68..3e8521e8 100644
--- a/helm-buffers.el
+++ b/helm-buffers.el
@@ -431,9 +431,18 @@ The list is reordered with `helm-buffer-list-reorder-fn'."
(append
(list
(concat prefix
- (propertize buf-name 'face face1
- 'help-echo help-echo
- 'type type)))
+ (let* ((buf-fname (buffer-file-name (get-buffer buf-name)))
+ (ext (if buf-fname (file-name-extension buf-fname) ""))
+ (buf-name (propertize buf-name 'face face1
+ 'help-echo help-echo
+ 'type type)))
+ (when (condition-case _err
+ (string-match (format "\\.\\(%s\\)" ext) buf-name)
+ (invalid-regexp nil))
+ (add-face-text-property
+ (match-beginning 1) (match-end 1)
+ 'helm-ff-file-extension nil buf-name))
+ buf-name)))
(and details
(list size mode
(propertize