From f1f134c40f63148a6c23494397818bab9cbff3f3 Mon Sep 17 00:00:00 2001 From: tastytea Date: Thu, 6 Feb 2020 20:13:30 +0100 Subject: [PATCH] Emacs: Rewrite icons-in-buffer-switcher thing. --- init.d/basics/ui.el | 74 ++++++++++++--------------------------------- 1 file changed, 20 insertions(+), 54 deletions(-) diff --git a/init.d/basics/ui.el b/init.d/basics/ui.el index 72367cd..249da95 100644 --- a/init.d/basics/ui.el +++ b/init.d/basics/ui.el @@ -1,6 +1,6 @@ ;;; ui.el --- Configure user interfaces. -*- lexical-binding: t; -*- -;; Time-stamp: <2020-02-03T06:37:56+0100> +;; Time-stamp: <2020-02-06T20:12:39+0100> ;;; Commentary: ;; * treemacs @@ -83,7 +83,8 @@ :functions (ivy-format-function-line) :config - (defun ivy-rich-switch-buffer-icon (candidate) + (defun my/ivy-rich-switch-buffer-icon (candidate) + "Return icon for `candidate'." (with-current-buffer (get-buffer candidate) (let ((icon (all-the-icons-icon-for-mode major-mode))) @@ -91,60 +92,25 @@ (all-the-icons-icon-for-mode 'fundamental-mode) icon)))) + ;; Add icons to buffer switcher. + ;; + (setq ivy-rich-display-transformers-list + (plist-put ivy-rich-display-transformers-list 'ivy-switch-buffer + '(:columns + ((my/ivy-rich-switch-buffer-icon (:width 1)) + (ivy-rich-candidate (:width 0.25)) + (ivy-rich-switch-buffer-size (:width 0.05 :face font-lock-comment-face)) + (ivy-rich-switch-buffer-indicators (:width 0.05 :face error :align right)) + (ivy-rich-switch-buffer-major-mode (:width 0.1 :face font-lock-function-name-face)) + (ivy-rich-switch-buffer-project (:width 0.15 :face success)) + (ivy-rich-switch-buffer-path (:width (lambda (x) (ivy-rich-switch-buffer-shorten-path x (ivy-rich-minibuffer-width 0.4))) :face font-lock-keyword-face))) + :predicate + (lambda (cand) (get-buffer cand)) + :delimiter "\t" + ))) + (ivy-rich-mode 1) (setcdr (assq t ivy-format-functions-alist) #'ivy-format-function-line) - - :custom - ;; It seems I have to copy this whole list to get icons in switch-buffer. - (ivy-rich-display-transformers-list - (quote - (ivy-switch-buffer - (:columns - ((ivy-rich-switch-buffer-icon (:width 2)) - (ivy-rich-candidate - (:width 30)) - (ivy-rich-switch-buffer-size - (:width 7)) - (ivy-rich-switch-buffer-indicators - (:width 4 :face error :align right)) - (ivy-rich-switch-buffer-major-mode - (:width 12 :face warning)) - (ivy-rich-switch-buffer-project - (:width 15 :face success)) - (ivy-rich-switch-buffer-path - (:width - (lambda - (x) - (ivy-rich-switch-buffer-shorten-path - x (ivy-rich-minibuffer-width 0.3)))))) - :predicate - (lambda - (cand) - (get-buffer cand))) - counsel-M-x - (:columns - ((counsel-M-x-transformer - (:width 40)) - (ivy-rich-counsel-function-docstring - (:face font-lock-doc-face)))) - counsel-describe-function - (:columns - ((counsel-describe-function-transformer - (:width 40)) - (ivy-rich-counsel-function-docstring - (:face font-lock-doc-face)))) - counsel-describe-variable - (:columns - ((counsel-describe-variable-transformer - (:width 40)) - (ivy-rich-counsel-variable-docstring - (:face font-lock-doc-face)))) - counsel-recentf - (:columns - ((ivy-rich-candidate - (:width 0.8)) - (ivy-rich-file-last-modified-time - (:face font-lock-comment-face))))))) ) (use-package ivy-purpose