Extend & compact doom/info

+ Output is now a couple lines shorter
+ Now tries to guess Linux distro names and versions
+ Displays symlinked EMACSDIR and DOOMDIR
+ Replaces elc-files segment with 'byte-compiled-config trait
This commit is contained in:
Henrik Lissner 2021-02-11 15:43:06 -05:00
parent 510bc7b5b4
commit 1a7536cbd1

View file

@ -111,23 +111,49 @@ ready to be pasted in a bug report on github."
(require 'core-packages)
(let ((default-directory doom-emacs-dir))
(letf! ((defun sh (&rest args) (cdr (apply #'doom-call-process args)))
(defun cat (file &optional limit)
(with-temp-buffer
(insert-file-contents file nil 0 limit)
(buffer-string)))
(defun abbrev-path (path)
(replace-regexp-in-string
(concat "\\<" (regexp-quote (user-login-name)) "\\>") "$USER"
(abbreviate-file-name path))))
(regexp-opt (list (user-login-name)) 'words) "$USER"
(abbreviate-file-name path)))
(defun symlink-path (file)
(format "%s%s" (abbrev-path file)
(if (file-symlink-p file)
(concat " -> " (file-truename file))
""))))
`((system
(type . ,system-type)
(config . ,system-configuration)
(info . ,(cons
(cond
(IS-WINDOWS "Windows")
(IS-MAC (format "MacOS "(sh "sw_vers" "-productVersion")))
((executable-find "lsb_release")
(sh "lsb_release" "-s" "-d"))
((executable-find "nixos-version")
(format "NixOS %s" (sh "nixos-version")))
((file-exists-p "/etc/os-release")
(let ((release (cat "/etc/os-release")))
(when (string-match "^PRETTY_NAME=\"\\([^\"]+\\)\"" release)
(match-string 1 release))))
((file-exists-p "/etc/debian_version")
(format "Debian %s" (car "/etc/debian_version")))
((when-let (files (doom-glob "/etc/*-release"))
(truncate-string-to-width
(replace-regexp-in-string "\n" " " (cat (car files) 73) nil t)
64 nil nil "...")))
((concat "Unknown " (sh "uname" "-v"))))
(sh "uname" "-msr")))
(shell . ,(abbrev-path shell-file-name))
(uname . ,(if IS-WINDOWS "n/a" (sh "uname" "-msrv")))
(path . ,(mapcar #'abbrev-path exec-path)))
(emacs
(dir . ,(abbrev-path (file-truename doom-emacs-dir)))
(version . ,emacs-version)
(build . ,(format-time-string "%b %d, %Y" emacs-build-time))
(dir . ,(symlink-path doom-emacs-dir))
(version . ,(delq nil (list emacs-version emacs-repository-version (format-time-string "%b %d, %Y" emacs-build-time))))
(buildopts . ,system-configuration-options)
(features . ,system-configuration-features)
(traits . ,(delq
(traits
. ,(delq
nil (list (cond ((not doom-interactive-p) 'batch)
((display-graphic-p) 'gui)
('tty))
@ -144,19 +170,18 @@ ready to be pasted in a bug report on github."
(if (file-symlink-p user-emacs-directory)
'symlinked-emacsdir)
(if (file-symlink-p doom-private-dir)
'symlinked-doomdir)))))
'symlinked-doomdir)
(if (doom-files-in `(,@doom-modules-dirs
,doom-core-dir
,doom-private-dir)
:type 'files :match "\\.elc$")
'byte-compiled-config)))))
(doom
(dir . ,(abbrev-path (file-truename doom-private-dir)))
(version . ,doom-version)
(dir . ,(symlink-path doom-private-dir))
(version . ,(list doom-version (sh "git" "log" "-1" "--format=%D %h %ci")))
,@(when doom-interactive-p
`((font . ,(bound-and-true-p doom-font))
(theme . ,(bound-and-true-p doom-theme))))
(build . ,(sh "git" "log" "-1" "--format=%D %h %ci"))
(elc-files
. ,(length (doom-files-in `(,@doom-modules-dirs
,doom-core-dir
,doom-private-dir)
:type 'files :match "\\.elc$")))
(modules
,@(or (cl-loop with cat = nil
for key being the hash-keys of doom-modules