fix(cli): show "restart Emacs" advice only if Emacs is running

Also fixes the case where it'll appear, unconditionally on 'doom
install', where the advice doesn't make sense.
This commit is contained in:
Henrik Lissner 2025-01-09 14:31:26 -05:00
parent 295cee7c78
commit eccd72922b
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

View file

@ -56,13 +56,21 @@ OPTIONS:
during the execution of this command. Use --rebuild as well to do so for all
packages."
:benchmark t
(when (doom-profiles-bootloadable-p)
(call! '(profile sync "--all" "--reload")))
(when aot?
(after! straight
(setq straight--native-comp-available t)))
(when jobs
(setq native-comp-async-jobs-number (truncate jobs)))
(let ((emacs-running?
(cl-loop for pid in (remove (emacs-pid) (list-system-processes))
for attrs = (process-attributes pid)
for args = (alist-get 'args attrs "")
if (string-match-p "^\\([^ ]+/\\)?[eE]macs" args)
if (not (string-match-p " --batch" args))
if (not (string-match-p " --script" args))
collect pid)))
(when (doom-profiles-bootloadable-p)
(call! '(profile sync "--all" "--reload")))
(run-hooks 'doom-before-sync-hook)
(add-hook 'kill-emacs-hook #'doom-sync--abort-warning-h)
(print! (item "Using Emacs %s @ %s") emacs-version (path invocation-directory invocation-name))
@ -100,14 +108,15 @@ OPTIONS:
(unless noupdate? (doom-packages-update (not update?)))
(doom-packages-purge purge? purge? purge? purge? purge?)
(when (doom-profile-generate)
(print! (item "Restart Emacs for changes to take effect"))
(when emacs-running?
(print! (item "Restart Emacs for changes to take effect")))
(run-hooks 'doom-after-sync-hook))
(when (or rebuild? (not (file-exists-p doom-sync-info-file)))
(with-temp-file doom-sync-info-file
(prin1 (cons emacs-version (doom-sync--system-hash))
(current-buffer))))
t)
(remove-hook 'kill-emacs-hook #'doom-sync--abort-warning-h)))
(remove-hook 'kill-emacs-hook #'doom-sync--abort-warning-h))))
;;