branch: externals/ivy-hydra
commit 22422dde13ffd77ac1fd0d442e92a4e893e57770
Author: Nathan Moreau <[email protected]>
Commit: Oleh Krehel <[email protected]>

    counsel.el (counsel-fonts): Add a custom transformer with font sample
    
    Fixes #2508
---
 counsel.el | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/counsel.el b/counsel.el
index cae8ff7..3386a5d 100644
--- a/counsel.el
+++ b/counsel.el
@@ -5388,6 +5388,15 @@ You can insert or kill the name of the selected font."
               :action #'insert
               :caller 'counsel-fonts)))
 
+(ivy-configure 'counsel-fonts
+  :display-transformer-fn #'counsel--font-with-sample)
+
+(defun counsel--font-with-sample (font-name)
+  "Format function for `counsel-fonts'."
+  (format "%-75s%s" font-name
+          (propertize "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
+                      'face (list :family font-name))))
+
 ;;** `counsel-kmacro'
 (defvar counsel-kmacro-map
   (let ((map (make-sparse-keymap)))

Reply via email to