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.
This commit is contained in:
Henrik Lissner 2018-05-19 12:07:11 +02:00
parent f16aa539c7
commit dcec3b9b25
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
2 changed files with 16 additions and 3 deletions

View file

@ -68,7 +68,8 @@ and enables `+popup-buffer-mode'."
ttl) ttl)
(when (and (buffer-file-name buffer) (when (and (buffer-file-name buffer)
(buffer-modified-p 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))) (with-current-buffer buffer (save-buffer)))
(set-buffer-modified-p nil) (set-buffer-modified-p nil)
(let ((ignore-window-parameters t)) (let ((ignore-window-parameters t))

View file

@ -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 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. 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) (popup . t)
This is for internal use, do not change this. It simply marks a window as a This is for internal use, do not change this. It simply marks a window as a
popup window. popup window.
@ -103,13 +115,13 @@ deleted.")
'((transient . 0) (quit . t))) '((transient . 0) (quit . t)))
(+popup-define "^\\*\\(?:scratch\\|Messages\\)" (+popup-define "^\\*\\(?:scratch\\|Messages\\)"
nil nil
'((transient))) '((autosave . t) (transient)))
(+popup-define "^\\*doom \\(?:term\\|eshell\\)" (+popup-define "^\\*doom \\(?:term\\|eshell\\)"
'((size . 0.25) (vslot . -10)) '((size . 0.25) (vslot . -10))
'((select . t) (quit) (transient . 0))) '((select . t) (quit) (transient . 0)))
(+popup-define "^\\*doom:" (+popup-define "^\\*doom:"
'((size . 0.35) (side . bottom)) '((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\\)" (+popup-define "^\\*\\(?:\\(?:Pp E\\|doom e\\)val\\)"
'((size . +popup-shrink-to-fit)) '((size . +popup-shrink-to-fit))
'((transient . 0) (select . ignore))) '((transient . 0) (select . ignore)))