From d00c5a0de503da5105238d43d12bfdd01a3f4f7f Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 25 Jul 2019 17:23:39 +0200 Subject: [PATCH] Add doom-cli-post-{failure,success}-execute-hook vars To replace doom-cli-post-execute-hook. Now only displays "refresh" message after a successful command. --- core/core-cli.el | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/core/core-cli.el b/core/core-cli.el index a3a9717e9..951a7009c 100644 --- a/core/core-cli.el +++ b/core/core-cli.el @@ -10,7 +10,7 @@ commands like `doom-packages-install', `doom-packages-update' and (defvar doom-cli-pre-execute-hook nil "TODO") -(defvar doom-cli-post-execute-hook nil +(defvar doom-cli-post-success-execute-hook nil "TODO") (defvar doom--cli-commands (make-hash-table :test 'equal)) @@ -98,15 +98,17 @@ If SHOW-HELP is non-nil, show the documentation for said dispatcher." (doom--dispatch-help fn args) (let ((start-time (current-time))) (run-hooks 'doom-cli-pre-execute-hook) - (when-let (ret (apply fn args)) - (print! - "\n%s" - (success "Finished! (%.4fs)" - (float-time - (time-subtract (current-time) - start-time)))) - (run-hooks 'doom-cli-post-execute-hook) - ret))))) + (unwind-protect + (when-let (ret (apply fn args)) + (print! + "\n%s" + (success "Finished! (%.4fs)" + (float-time + (time-subtract (current-time) + start-time)))) + (run-hooks 'doom-cli-post-execute-hook) + ret) + (run-hooks 'doom-cli-post-error-execute-hook)))))) (defmacro def-command-group! (name docstring &rest body) "TODO"