From 88881bfbe1af20f946b3c63b6316043ceec27104 Mon Sep 17 00:00:00 2001 From: Mohsin Kaleem Date: Sat, 11 Mar 2023 22:30:32 +0000 Subject: [PATCH 1/3] Make icon display predicate customizeable --- dashboard-widgets.el | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/dashboard-widgets.el b/dashboard-widgets.el index a90ed33..5ced02d 100644 --- a/dashboard-widgets.el +++ b/dashboard-widgets.el @@ -195,8 +195,21 @@ Example: :type 'string :group 'dashboard) +(defcustom dashboard-display-icons-p #'display-graphic-p + "Predicate to determine whether dashboard should show icons. +Can be nil to not show icons and any truthy value to show them. When set +to a function the result of the function will be interpreted as the +predicate value." + :type '(choice (function :tag "Predicate function") + (boolean :tag "Predicate value"))) + +(defun dashboard-display-icons-p () + (if (functionp dashboard-display-icons-p) + (funcall dashboard-display-icons-p) + dashboard-display-icons-p)) + (defcustom dashboard-footer-icon - (if (and (display-graphic-p) + (if (and (dashboard-display-icons-p) (or (fboundp 'all-the-icons-fileicon) (require 'all-the-icons nil 'noerror))) (all-the-icons-fileicon "emacs" @@ -459,7 +472,7 @@ If MESSAGEBUF is not nil then MSG is also written in message buffer." (defun dashboard-insert-heading (heading &optional shortcut) "Insert a widget HEADING in dashboard buffer, adding SHORTCUT if provided." - (when (and (display-graphic-p) dashboard-set-heading-icons) + (when (and (dashboard-display-icons-p) dashboard-set-heading-icons) ;; Try loading `all-the-icons' (unless (or (fboundp 'all-the-icons-octicon) (require 'all-the-icons nil 'noerror)) @@ -729,7 +742,7 @@ to widget creation." (let ((tag ,@rest)) (insert "\n ") - (when (and (display-graphic-p) + (when (and (dashboard-display-icons-p) dashboard-set-file-icons (or (fboundp 'all-the-icons-icon-for-dir) (require 'all-the-icons nil 'noerror))) From db0904e8f8d4051c63f0fb5a300423689b51eeed Mon Sep 17 00:00:00 2001 From: Mohsin Kaleem Date: Sun, 12 Mar 2023 00:14:24 +0000 Subject: [PATCH 2/3] review: Document new predicate function --- dashboard-widgets.el | 1 + 1 file changed, 1 insertion(+) diff --git a/dashboard-widgets.el b/dashboard-widgets.el index 5ced02d..024630e 100644 --- a/dashboard-widgets.el +++ b/dashboard-widgets.el @@ -204,6 +204,7 @@ predicate value." (boolean :tag "Predicate value"))) (defun dashboard-display-icons-p () + "Assert whether to show icons based on the `dashboard-display-icons-p' variable." (if (functionp dashboard-display-icons-p) (funcall dashboard-display-icons-p) dashboard-display-icons-p)) From f9c53fb2ec291d57a281834b35e625b8f3c6d97c Mon Sep 17 00:00:00 2001 From: Mohsin Kaleem Date: Sun, 12 Mar 2023 01:22:15 +0000 Subject: [PATCH 3/3] review: Add group for new icons predicate --- dashboard-widgets.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dashboard-widgets.el b/dashboard-widgets.el index 024630e..423f402 100644 --- a/dashboard-widgets.el +++ b/dashboard-widgets.el @@ -201,7 +201,8 @@ Can be nil to not show icons and any truthy value to show them. When set to a function the result of the function will be interpreted as the predicate value." :type '(choice (function :tag "Predicate function") - (boolean :tag "Predicate value"))) + (boolean :tag "Predicate value")) + :group 'dashboard) (defun dashboard-display-icons-p () "Assert whether to show icons based on the `dashboard-display-icons-p' variable."