From dcec3b9b25043152beb9c1972195d612e264bc94 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sat, 19 May 2018 12:07:11 +0200 Subject: [PATCH] feature/popup: add new autosave window parameter (autosave . CDR) This parameter determines what to do with modified buffers in closing popup windows. CDR can be a t, 'ignore, a function or nil. + If t, no prompts. Just save them automatically (if they're file-visiting buffers). + If 'ignore, no prompts, no saving. Just silently kill it. + If nil (the default), prompt the user what to do if the buffer is file-visiting and modified. + If a function, the return value must return one of the other values. It takes two arguments: the popup window and buffer. --- modules/ui/popup/autoload.el | 3 ++- modules/ui/popup/config.el | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/modules/ui/popup/autoload.el b/modules/ui/popup/autoload.el index 8b33d7d91..844e3d1ef 100644 --- a/modules/ui/popup/autoload.el +++ b/modules/ui/popup/autoload.el @@ -68,7 +68,8 @@ and enables `+popup-buffer-mode'." ttl) (when (and (buffer-file-name buffer) (buffer-modified-p buffer) - (y-or-n-p "Popup buffer is modified. Save it?")) + (or (+popup-parameter-fn 'autosave window buffer) + (y-or-n-p "Popup buffer is modified. Save it?"))) (with-current-buffer buffer (save-buffer))) (set-buffer-modified-p nil) (let ((ignore-window-parameters t)) diff --git a/modules/ui/popup/config.el b/modules/ui/popup/config.el index 62c201748..d83c8d708 100644 --- a/modules/ui/popup/config.el +++ b/modules/ui/popup/config.el @@ -45,6 +45,18 @@ Modifying this has no effect, unless done before ui/popup loads. modeline defined with `def-modeline!', nil (show no modeline) or a function that returns one of these. The function takes one argument: the popup buffer. +(autosave . CDR) + This parameter determines what to do with modified buffers in closing popup + windows. CDR can be a t, 'ignore, a function or nil. + + If t, no prompts. Just save them automatically (if they're file-visiting + buffers). + If 'ignore, no prompts, no saving. Just silently kill it. + If nil (the default), prompt the user what to do if the buffer is + file-visiting and modified. + If a function, the return value must return one of the other values. It takes + two arguments: the popup window and buffer. + (popup . t) This is for internal use, do not change this. It simply marks a window as a popup window. @@ -103,13 +115,13 @@ deleted.") '((transient . 0) (quit . t))) (+popup-define "^\\*\\(?:scratch\\|Messages\\)" nil - '((transient))) + '((autosave . t) (transient))) (+popup-define "^\\*doom \\(?:term\\|eshell\\)" '((size . 0.25) (vslot . -10)) '((select . t) (quit) (transient . 0))) (+popup-define "^\\*doom:" '((size . 0.35) (side . bottom)) - '((select . t) (modeline . t) (quit) (transient . t))) + '((autosave . t) (select . t) (modeline . t) (quit) (transient . t))) (+popup-define "^\\*\\(?:\\(?:Pp E\\|doom e\\)val\\)" '((size . +popup-shrink-to-fit)) '((transient . 0) (select . ignore)))