From 409afb58f365d609c80c598a5de687213c027065 Mon Sep 17 00:00:00 2001 From: JSDurand Date: Sun, 18 Jun 2023 17:06:03 +0800 Subject: desktop and bookmark: proper save mechanism * bookmark-conf.el (durand-saving-bookmarks): This variable indicates whether or not we are saving bookmarks already. (#'bookmark-write-file): Just a formating change. (durand-save-bookmark-or-desktop): Save bookmarks and/or the desktop file, depending on its argument. (ctl-x-r-map): Bind 'C-x r s' to `durand-save-bookmark-or-desktop`. * desktop-conf.el (durand-saving-bookmarks): In case this variable is not defined, silence the errors. (desktop-also-save-bookmarks): If we are not already saving bookmarks, save the bookmarks as well. (desktop-save-hook): Add `desktop-also-save-bookmarks` to this hook, so that when saving desktop and not already saving bookmarks, Emacs can automatically save bookmarks as well. --- desktop-conf.el | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'desktop-conf.el') diff --git a/desktop-conf.el b/desktop-conf.el index 462c549..074aad0 100644 --- a/desktop-conf.el +++ b/desktop-conf.el @@ -198,5 +198,17 @@ no questions asked." (desktop-save-mode 1) +;;; Add a hook to save bookmarks if we are not already saving them. + +(defvar durand-saving-bookmarks) + +(defun desktop-also-save-bookmarks () + "Save bookmarks if we are not already saving bookmarks." + (cond + ((and (functionp #'bookmark-save) (not durand-saving-bookmarks)) + (bookmark-save)))) + +(add-hook 'desktop-save-hook #'desktop-also-save-bookmarks) + (provide 'desktop-conf) ;;; desktop-conf.el ends here -- cgit v1.2.3-18-g5258