core-cli: backport more refactors from rewrite

Still a long way to go, but this introduces a few niceties for
debugging CLI failures:

+ The (extended) output of the last bin/doom command is now logged to
  ~/.emacs.d/.local/doom.log
+ If an error occurs, short backtraces are displayed whether or not you
  have debug mode on. The full backtrace is written to
  ~/.emacs.d/.local/doom.error.log.
+ bin/doom now aborts with a warning if:
  - The script itself or its parent directory is a symlink. It's fine if
    ~/.emacs.d is symlinked though.
  - Running bin/doom as root when your DOOMDIR isn't in /root/.
  - If you're sporting Emacs 26.1 (now handled in the elisp side rather
    than the /bin/sh shebang preamble).
+ If a 'doom sync' was aborted prematurely, you'll be warned that Doom
  was left in an inconsistent state and that you must run `doom sync`
  again.

May address #3746
This commit is contained in:
Henrik Lissner 2020-08-24 00:36:52 -04:00
parent 7e362e8fbd
commit e632871a11
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
11 changed files with 393 additions and 242 deletions

View file

@ -98,7 +98,7 @@ Runs `doom-reload-hook' afterwards."
;;;###autoload
(defun doom/reload-autoloads ()
"Reload only `doom-autoload-file' and `doom-package-autoload-file'.
"Reload only `doom-autoloads-file' and `doom-package-autoload-file'.
This is much faster and safer than `doom/reload', but not as comprehensive. This
reloads your package and module visibility, but does not install new packages or

View file

@ -146,8 +146,9 @@ If COOKIE doesn't exist, return NULL-VALUE."
(insert-file-contents file nil 0 256)
(if (re-search-forward (format "^;;;###%s " (regexp-quote (or cookie "if")))
nil t)
(let ((load-file-name file))
(eval (sexp-at-point) t))
(or (let ((load-file-name file))
(eval (sexp-at-point) t))
null-value)
null-value)))
;;;###autoload

View file

@ -254,8 +254,12 @@ DEST can be one or more of `standard-output', a buffer, a file"
(insert-char out))
(send-string-to-terminal (char-to-string out)))))
(letf! (defun message (msg &rest args)
(princ (apply #'format msg args))
(terpri))
(with-current-buffer log-buffer
(print-group!
(insert (doom--format (apply #'format msg args)) "\n")))
(if doom-debug-p
(doom--print (doom--format (apply #'format msg args)))
(apply message msg args)))
(unwind-protect
,(macroexp-progn body)
(with-current-buffer log-buffer