From 6b7f97f4fc14f25b52c0a5e27a76406e2f5c8309 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 20 Aug 2018 23:56:56 +0200 Subject: [PATCH] Autoload doom-quit-p & revise its docstring --- core/autoload/ui.el | 12 ++++++++++++ core/core-ui.el | 13 ++----------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/core/autoload/ui.el b/core/autoload/ui.el index af357eeaf..71ae4297c 100644 --- a/core/autoload/ui.el +++ b/core/autoload/ui.el @@ -124,3 +124,15 @@ to a new one." ;;;###autoload (defun doom*recenter (&rest _) (recenter)) + +;;;###autoload +(defun doom-quit-p (&optional prompt) + "Prompt the user for confirmation when killing Emacs. + +Returns t if it is safe to kill this session. Does not prompt if no real buffers +are open." + "Return t if this session should be killed silently." + (if (ignore-errors (doom-real-buffer-list)) + (or (yes-or-no-p (format "››› %s" (or prompt "Quit Emacs?"))) + (ignore (message "Aborted"))) + t)) diff --git a/core/core-ui.el b/core/core-ui.el index a4cc2d24e..11a3f638f 100644 --- a/core/core-ui.el +++ b/core/core-ui.el @@ -36,7 +36,8 @@ shorter major mode name in the mode-line. See `doom|set-mode-name'.") compilation-ask-about-save nil ; save all buffers on `compile' compilation-scroll-output 'first-error confirm-nonexistent-file-or-buffer t - cursor-in-non-selected-windows nil ; hide cursors in other windows + confirm-kill-emacs #'doom-quit-p ; custom confirmation when killing Emacs + cursor-in-non-selected-windows nil ; hide cursors in other windows custom-theme-directory (expand-file-name "themes/" doom-private-dir) display-line-numbers-width 3 enable-recursive-minibuffers nil @@ -490,16 +491,6 @@ frame's window-system, the theme will be reloaded.") (add-hook 'doom-escape-hook #'doom|delete-posframe-on-escape) (add-hook 'doom-cleanup-hook #'posframe-delete-all)) -;; Customized confirmation prompt for quitting Emacs -(defun doom-quit-p (&optional prompt) - "Return t if this session should be killed. Prompts the user for -confirmation." - (if (ignore-errors (doom-real-buffer-list)) - (or (yes-or-no-p (format "››› %s" (or prompt "Quit Emacs?"))) - (ignore (message "Aborted"))) - t)) -(setq confirm-kill-emacs #'doom-quit-p) - (defun doom|compilation-ansi-color-apply () "Applies ansi codes to the compilation buffers. Meant for `compilation-filter-hook'."