mirror of
https://github.com/vale981/emacs-ipython-notebook
synced 2025-03-06 09:31:39 -05:00
Improve ein:notebook-ask-before-kill-emacs
It was needed to answer `y' when killing Emacs and there exists unsaved buffers. This change eliminate the need for that by killing buffers forcefully.
This commit is contained in:
parent
422adbdd2b
commit
7b93f7c647
1 changed files with 17 additions and 4 deletions
|
@ -990,10 +990,17 @@ Examples:
|
|||
(or (ein:$notebook-dirty ein:notebook)
|
||||
(buffer-modified-p))))))
|
||||
|
||||
(defcustom ein:notebook-kill-buffer-ask t
|
||||
"Whether EIN should ask before killing unsaved notebook buffer."
|
||||
:type '(choice (const :tag "Yes" t)
|
||||
(const :tag "No" nil))
|
||||
:group 'ein)
|
||||
|
||||
(defun ein:notebook-ask-before-kill-buffer ()
|
||||
"Return `nil' to prevent killing the notebook buffer.
|
||||
Called via `kill-buffer-query-functions'."
|
||||
(not (and (ein:notebook-modified-p)
|
||||
(not (and ein:notebook-kill-buffer-ask
|
||||
(ein:notebook-modified-p)
|
||||
(not (y-or-n-p "You have unsaved changes. Discard changes?")))))
|
||||
|
||||
(add-hook 'kill-buffer-query-functions 'ein:notebook-ask-before-kill-buffer)
|
||||
|
@ -1016,9 +1023,15 @@ Called via `kill-emacs-query-functions'."
|
|||
(ein:notebook-opened-buffers))))
|
||||
(if (null unsaved)
|
||||
t
|
||||
(y-or-n-p
|
||||
(format "You have %s unsaved notebook(s). Discard changes?"
|
||||
(length unsaved))))))
|
||||
(let ((answer
|
||||
(y-or-n-p
|
||||
(format "You have %s unsaved notebook(s). Discard changes?"
|
||||
(length unsaved)))))
|
||||
;; kill all unsaved buffers forcefully
|
||||
(when answer
|
||||
(let ((ein:notebook-kill-buffer-ask nil))
|
||||
(mapc #'kill-buffer unsaved)))
|
||||
answer))))
|
||||
|
||||
(add-hook 'kill-emacs-query-functions 'ein:notebook-ask-before-kill-emacs)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue