summaryrefslogtreecommitdiff
path: root/desktop-conf.el
diff options
context:
space:
mode:
authorJSDurand <mmemmew@gmail.com>2023-06-18 17:06:03 +0800
committerJSDurand <mmemmew@gmail.com>2023-06-18 17:06:03 +0800
commit409afb58f365d609c80c598a5de687213c027065 (patch)
tree4b41bddb6449f2eab5662dc90f992cbde71db4cb /desktop-conf.el
parent3d8fffd03f44e5734e96cb76ea5b29b544955697 (diff)
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.
Diffstat (limited to 'desktop-conf.el')
-rw-r--r--desktop-conf.el12
1 files changed, 12 insertions, 0 deletions
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