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

@ -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