From 798e10c4f2bfaee75c889935e1b7e49152628d8a Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 18 Jun 2019 17:29:50 +0200 Subject: [PATCH] Refactor doom doctor And move font check into core/doctor.el --- bin/doom-doctor | 35 +++++------------------------------ core/doctor.el | 26 ++++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 32 deletions(-) diff --git a/bin/doom-doctor b/bin/doom-doctor index 1c733249a..aec1a4bcd 100755 --- a/bin/doom-doctor +++ b/bin/doom-doctor @@ -38,10 +38,10 @@ ;;; Helpers -(defun sh (cmd) +(defun sh (cmd &rest args) (ignore-errors (string-trim-right - (shell-command-to-string cmd)))) + (shell-command-to-string (format cmd args))))) (defun elc-check-dir (dir) (dolist (file (directory-files-recursively dir "\\.elc$")) @@ -184,29 +184,6 @@ (warn! "Warning: Windows detected") (explain! "DOOM was designed for MacOS and Linux. Expect a bumpy ride!")) - ;; are all default fonts present? - (section! "Checking your fonts...") - (if (not (fboundp 'find-font)) - (progn - (warn! "Warning: unable to detect font") - (explain! "The `find-font' function is missing. This could indicate the incorrect " - "version of Emacs is being used!")) - ;; all-the-icons fonts - (let ((font-dest (pcase system-type - (`gnu/linux (concat (or (getenv "XDG_DATA_HOME") - "~/.local/share") - "/fonts/")) - (`darwin "~/Library/Fonts/")))) - (when (and font-dest (require 'all-the-icons nil t)) - (dolist (font all-the-icons-font-names) - (if (file-exists-p (expand-file-name font font-dest)) - (success! "Found font %s" font) - (warn! "Warning: couldn't find %s font in %s" - font font-dest) - (explain! "You can install it by running `M-x all-the-icons-install-fonts' within Emacs.\n\n" - "This could also mean you've installed them in non-standard locations, in which " - "case feel free to ignore this warning.")))))) - ;; gnutls-cli & openssl (section! "Checking gnutls/openssl...") (cond ((executable-find "gnutls-cli")) @@ -231,7 +208,7 @@ (t (error! "Important: couldn't find either gnutls-cli nor openssl") (explain! - "You won't be able to install/update packages because Emacs won't be able to " + "You may not be able to install/update packages because Emacs won't be able to " "verify HTTPS ELPA sources. Install gnutls-cli or openssl v1.0.0+. If for some " "reason you can't, you can bypass this verification with the INSECURE flag:\n\n" @@ -288,16 +265,14 @@ (`empty (error! "Couldn't reach %s" url)) (`timeout (error! "Timed out trying to contact %s" ex)) (_ - (error! "Validated %s (this shouldn't happen!)" url)))))) - - ((error! "Nope!"))) + (error! "Validated %s (this shouldn't happen!)" url))))))) ;; which variant of tar is on your system? bsd or gnu tar? (section! "Checking for GNU/BSD tar...") (let ((tar-bin (or (executable-find "gtar") (executable-find "tar")))) (if tar-bin - (unless (string-match-p "(GNU tar)" (sh (format "%s --version" tar-bin))) + (unless (string-match-p "(GNU tar)" (sh "%s --version" tar-bin)) (warn! "Warning: BSD tar detected") (explain! "QUELPA (through package-build) uses the system tar to build plugins, but it " diff --git a/core/doctor.el b/core/doctor.el index 296dfae64..d5466a28e 100644 --- a/core/doctor.el +++ b/core/doctor.el @@ -33,5 +33,27 @@ (file-directory-p "~/.doom.d")) (warn! "Both %S and '~/.doom.d' exist on your system" (abbreviate-file-name doom-private-dir)) - (explain! "Doom will only load one of these (~/.config/doom takes precedence). Since\n" - "it is rarely intentional that you have both, ~/.doom.d should be removed.")) + (explain! "Doom will only load one of these (~/.config/doom takes precedence). Possessing\n" + "both is rarely intentional; you should one or the other.")) + +;; Check for fonts +(if (not (fboundp 'find-font)) + (progn + (warn! "Warning: unable to detect font") + (explain! "The `find-font' function is missing. This could indicate the incorrect " + "version of Emacs is being used!")) + ;; all-the-icons fonts + (let ((font-dest (pcase system-type + (`gnu/linux (concat (or (getenv "XDG_DATA_HOME") + "~/.local/share") + "/fonts/")) + (`darwin "~/Library/Fonts/")))) + (when (and font-dest (require 'all-the-icons nil t)) + (dolist (font all-the-icons-font-families) + (if (sh "fc-list | grep %s" font) + (success! "Found font %s" font) + (warn! "Warning: couldn't find %s font in %s" + font font-dest) + (explain! "You can install it by running `M-x all-the-icons-install-fonts' within Emacs.\n\n" + "This could also mean you've installed them in non-standard locations, in which " + "case feel free to ignore this warning."))))))