Refactor & fix doom-doctor module checkups
This commit is contained in:
parent
afdf2047a7
commit
82bead5ae4
2 changed files with 41 additions and 51 deletions
|
@ -11,15 +11,11 @@
|
||||||
|
|
||||||
(unless (file-directory-p user-emacs-directory)
|
(unless (file-directory-p user-emacs-directory)
|
||||||
(error "Couldn't find a Doom config!"))
|
(error "Couldn't find a Doom config!"))
|
||||||
|
(unless noninteractive
|
||||||
|
(error "This script must not be run from an interactive session."))
|
||||||
|
|
||||||
(require 'pp)
|
(require 'pp)
|
||||||
|
|
||||||
;; subr-x may not exist in the current version of Emacs
|
|
||||||
(defsubst string-trim-right (string &optional regexp)
|
|
||||||
(if (string-match (concat "\\(?:" (or regexp "[ \t\n\r]+") "\\)\\'") string)
|
|
||||||
(replace-match "" t t string)
|
|
||||||
string))
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
(defvar doom-init-p nil)
|
(defvar doom-init-p nil)
|
||||||
(defvar doom-errors 0)
|
(defvar doom-errors 0)
|
||||||
|
@ -52,22 +48,6 @@
|
||||||
(fill-region (point-min) (point-max))
|
(fill-region (point-min) (point-max))
|
||||||
(buffer-string))))
|
(buffer-string))))
|
||||||
|
|
||||||
(defun columns (cols length strings)
|
|
||||||
(declare (indent defun))
|
|
||||||
(with-temp-buffer
|
|
||||||
(let ((sub-format (format "%%-%ds " (1- length)))
|
|
||||||
col-format)
|
|
||||||
(dotimes (i (1- cols))
|
|
||||||
(setq col-format (concat col-format sub-format)))
|
|
||||||
(setq col-format (concat col-format "%s"))
|
|
||||||
(while strings
|
|
||||||
(insert (apply #'format col-format
|
|
||||||
(let (args)
|
|
||||||
(dotimes (i cols (nreverse args))
|
|
||||||
(push (if strings (pop strings) "") args))))
|
|
||||||
"\n")))
|
|
||||||
(buffer-string)))
|
|
||||||
|
|
||||||
(defun sh (cmd)
|
(defun sh (cmd)
|
||||||
(string-trim-right (shell-command-to-string cmd)))
|
(string-trim-right (shell-command-to-string cmd)))
|
||||||
|
|
||||||
|
@ -75,8 +55,12 @@
|
||||||
(format "\e[%dm%s\e[%dm" code (apply #'format msg args) 0))
|
(format "\e[%dm%s\e[%dm" code (apply #'format msg args) 0))
|
||||||
|
|
||||||
(defvar indent 0)
|
(defvar indent 0)
|
||||||
|
(defvar prefix "")
|
||||||
(defmacro msg! (msg &rest args)
|
(defmacro msg! (msg &rest args)
|
||||||
`(message (indented indent (format ,msg ,@args))))
|
`(message
|
||||||
|
(indented indent
|
||||||
|
(format (concat prefix ,msg)
|
||||||
|
,@args))))
|
||||||
(defmacro error! (&rest args) `(progn (msg! (color 31 ,@args)) (setq doom-errors (+ doom-errors 1))))
|
(defmacro error! (&rest args) `(progn (msg! (color 31 ,@args)) (setq doom-errors (+ doom-errors 1))))
|
||||||
(defmacro warn! (&rest args) `(progn (msg! (color 33 ,@args)) (setq doom-errors (+ doom-errors 1))))
|
(defmacro warn! (&rest args) `(progn (msg! (color 33 ,@args)) (setq doom-errors (+ doom-errors 1))))
|
||||||
(defmacro success! (&rest args) `(msg! (color 32 ,@args)))
|
(defmacro success! (&rest args) `(msg! (color 32 ,@args)))
|
||||||
|
@ -93,12 +77,19 @@
|
||||||
(save-match-data
|
(save-match-data
|
||||||
(string-match regexp string &optional start))))
|
(string-match regexp string &optional start))))
|
||||||
|
|
||||||
|
;; subr-x may not exist in the current version of Emacs
|
||||||
|
(unless (fboundp 'string-trim-right)
|
||||||
|
(defsubst string-trim-right (string &optional regexp)
|
||||||
|
(if (string-match (concat "\\(?:" (or regexp "[ \t\n\r]+") "\\)\\'") string)
|
||||||
|
(replace-match "" t t string)
|
||||||
|
string)))
|
||||||
|
|
||||||
|
|
||||||
;; --- start a'doctorin' --------------------------------------
|
;; --- start a'doctorin' --------------------------------------
|
||||||
|
|
||||||
(msg! "%s" (color 1 "DOOM Doctor"))
|
(msg! (color 1 "Doom Doctor"))
|
||||||
(msg! "Emacs v%s" emacs-version)
|
(msg! "Emacs v%s" emacs-version)
|
||||||
(msg! "Doom v%s"
|
(msg! "Doom v%s (%s)"
|
||||||
(or (and (file-exists-p (expand-file-name "core/core.el" user-emacs-directory))
|
(or (and (file-exists-p (expand-file-name "core/core.el" user-emacs-directory))
|
||||||
(with-temp-buffer
|
(with-temp-buffer
|
||||||
(insert-file-contents-literally
|
(insert-file-contents-literally
|
||||||
|
@ -107,21 +98,19 @@
|
||||||
(when (re-search-forward "doom-version")
|
(when (re-search-forward "doom-version")
|
||||||
(forward-char)
|
(forward-char)
|
||||||
(sexp-at-point))))
|
(sexp-at-point))))
|
||||||
"???"))
|
"???")
|
||||||
(msg! "Commit %s"
|
|
||||||
(if (and (executable-find "git")
|
(if (and (executable-find "git")
|
||||||
(file-directory-p (expand-file-name ".git" user-emacs-directory)))
|
(file-directory-p (expand-file-name ".git" user-emacs-directory)))
|
||||||
(sh "git rev-parse HEAD")
|
(substring (sh "git rev-parse HEAD") 0 8)
|
||||||
"n/a"))
|
"n/a"))
|
||||||
|
|
||||||
(msg! "shell: %s%s"
|
(msg! "shell: %s%s"
|
||||||
(getenv "SHELL")
|
(getenv "SHELL")
|
||||||
(if (equal (getenv "SHELL") (sh "echo $SHELL"))
|
(if (equal (getenv "SHELL") (sh "echo $SHELL"))
|
||||||
""
|
""
|
||||||
(color 31 " (mismatch)")))
|
(color 31 " (mismatch)")))
|
||||||
(when (boundp 'system-configuration-features)
|
(when (boundp 'system-configuration-features)
|
||||||
(msg! "Compiled with:\n%s" (indented 2 (autofill system-configuration-features))))
|
(message "Compiled with:\n%s" (indented 2 system-configuration-features)))
|
||||||
(msg! "uname -a:\n%s\n" (indented 2 (autofill (sh "uname -a"))))
|
(message "uname -a:\n%s\n" (indented 2 (sh "uname -a")))
|
||||||
|
|
||||||
(msg! "----\n")
|
(msg! "----\n")
|
||||||
|
|
||||||
|
@ -279,23 +268,26 @@
|
||||||
(let (doom-core-packages doom-debug-mode)
|
(let (doom-core-packages doom-debug-mode)
|
||||||
(condition-case ex
|
(condition-case ex
|
||||||
(progn
|
(progn
|
||||||
|
(let (noninteractive)
|
||||||
|
(load "~/.emacs.d/core/core.el" nil t))
|
||||||
(let ((inhibit-message t)
|
(let ((inhibit-message t)
|
||||||
noninteractive)
|
(noninteractive t))
|
||||||
(load "~/.emacs.d/init.el" nil t))
|
(load "~/.emacs.d/init.el" nil t))
|
||||||
(doom-initialize-packages)
|
(doom-initialize-packages t)
|
||||||
|
(quiet! (doom-initialize-modules))
|
||||||
(doom|finalize)
|
(doom|finalize)
|
||||||
(success! "Attempt to load DOOM: success! Loaded v%s" doom-version)
|
(success! "Attempt to load DOOM: success! Loaded v%s" doom-version))
|
||||||
(when (executable-find "git")
|
('error
|
||||||
(msg! "Revision %s\n"
|
(warn! "Attempt to load DOOM: failed\n %s\n"
|
||||||
(ignore-errors
|
(or (cdr-safe ex) (car ex)))
|
||||||
(let ((default-directory user-emacs-directory))
|
(setq doom-modules nil))))
|
||||||
(sh "git rev-parse HEAD"))))))
|
|
||||||
('error (warn! "Attempt to load DOOM: failed\n %s\n"
|
|
||||||
(or (cdr-safe ex) (car ex))))))
|
|
||||||
|
|
||||||
(when (bound-and-true-p doom-modules)
|
(when (bound-and-true-p doom-modules)
|
||||||
(section! "test-modules")
|
(section! "test-modules")
|
||||||
(let ((indent 4))
|
(let ((indent 4))
|
||||||
|
(defun --quiet-require (orig-fn &rest args)
|
||||||
|
(quiet! (apply orig-fn args)))
|
||||||
|
(advice-add #'require :around #'--quiet-require)
|
||||||
(maphash
|
(maphash
|
||||||
(lambda (key plist)
|
(lambda (key plist)
|
||||||
(condition-case ex
|
(condition-case ex
|
||||||
|
@ -304,13 +296,11 @@
|
||||||
doom-packages)
|
doom-packages)
|
||||||
(when (or (file-exists-p doctor-file)
|
(when (or (file-exists-p doctor-file)
|
||||||
(file-exists-p packages-file))
|
(file-exists-p packages-file))
|
||||||
(let ((indent 2))
|
(let ((prefix (format "%s" (color 1 "(%s %s) " (car key) (cdr key)))))
|
||||||
(section! "test-module -> %s %s" (car key) (cdr key)))
|
|
||||||
(load packages-file t t)
|
|
||||||
(when (load packages-file t t)
|
(when (load packages-file t t)
|
||||||
(dolist (package (cl-remove-if #'package-installed-p doom-packages :key #'car))
|
(dolist (package (cl-remove-if #'package-installed-p doom-packages :key #'car))
|
||||||
(error! "%s is not installed" (car package))))
|
(error! "%s is not installed" (car package))))
|
||||||
(load doctor-file t t)))
|
(load doctor-file t t))))
|
||||||
('error
|
('error
|
||||||
(error! "Syntax error: %s" ex))))
|
(error! "Syntax error: %s" ex))))
|
||||||
doom-modules)))
|
doom-modules)))
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
(unless (executable-find "gore")
|
(unless (executable-find "gore")
|
||||||
(warn! "Couldn't find gore. REPL will not work"))
|
(warn! "Couldn't find gore. REPL will not work"))
|
||||||
|
|
||||||
(when (and (featurep! :completion company)
|
(when (featurep! :completion company)
|
||||||
(require 'company-go nil t))
|
(require 'company-go)
|
||||||
(unless (executable-find command-go-gocode-command)
|
(unless (executable-find command-go-gocode-command)
|
||||||
(warn! "Couldn't find gocode. Code completion won't work")))
|
(warn! "Couldn't find gocode. Code completion won't work")))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue