[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ebdb 93004c8 3/4: Change logic of saving on Emacs exit
From: |
Eric Abrahamsen |
Subject: |
[elpa] externals/ebdb 93004c8 3/4: Change logic of saving on Emacs exit |
Date: |
Thu, 9 Jan 2020 18:05:08 -0500 (EST) |
branch: externals/ebdb
commit 93004c8a7b13ee41a9245d4bd421685993602dce
Author: Eric Abrahamsen <address@hidden>
Commit: Eric Abrahamsen <address@hidden>
Change logic of saving on Emacs exit
See bug#38993, thanks to Jorge P. de Morais Neto for suggestions
* ebdb.el (ebdb-save-on-emacs-exit): New function specially for use as
a kill-emacs-hook. Honor the current value of ebdb-save-on-exit here.
(ebdb-load): Add the above function as a kill-emacs-hook regardless
of the value of ebdb-save-on-exit.
---
ebdb.el | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/ebdb.el b/ebdb.el
index 23240ca..019b6cb 100644
--- a/ebdb.el
+++ b/ebdb.el
@@ -5075,8 +5075,7 @@ All the important work is done by the `ebdb-db-load'
method."
(run-hooks 'ebdb-after-load-hook)
(when ebdb-use-diary
(add-hook 'diary-list-entries-hook #'ebdb-diary-add-entries))
- (when ebdb-save-on-exit
- (add-hook 'kill-emacs-hook #'ebdb-save))
+ (add-hook 'kill-emacs-hook #'ebdb-save-on-emacs-exit)
(length ebdb-record-tracker)))
;; If we wanted to make it seem like EBDB was loading faster, we could
@@ -5202,7 +5201,7 @@ This is a generic function that dispatches on the value of
-;;; Loading and saving EBDB
+;;; Saving EBDB.
(defun ebdb-save (&optional interactive)
"Save the EBDB if it is modified.
@@ -5217,7 +5216,14 @@ additionally prompt to save each database individually."
(ebdb-db-save s (eq interactive 4)))
(run-hooks 'ebdb-after-save-hook)
(when interactive
- (message "Saving the EBDB... done")))
+ (message "Saving the EBDB... done")))
+
+(defun ebdb-save-on-emacs-exit ()
+ "Possibly save EBDB when exiting Emacs.
+See option `ebdb-save-on-exit'."
+ (when ebdb-save-on-exit
+ ;; `kill-emacs-hook' functions should not interact with the user.
+ (ebdb-save)))
;;; Searching EBDB