summaryrefslogtreecommitdiff
path: root/bookmark-conf.el
diff options
context:
space:
mode:
Diffstat (limited to 'bookmark-conf.el')
-rw-r--r--bookmark-conf.el30
1 files changed, 29 insertions, 1 deletions
diff --git a/bookmark-conf.el b/bookmark-conf.el
index 074628f..eddb3d5 100644
--- a/bookmark-conf.el
+++ b/bookmark-conf.el
@@ -442,8 +442,36 @@ Modified by Durand to use `print' instead of `pp'.
(kill-buffer (current-buffer))
(progress-reporter-done reporter))))))
-(advice-add #'bookmark-write-file :override #'durand-bookmark-write-file)
+(advice-add #'bookmark-write-file :override
+ #'durand-bookmark-write-file)
+;;; Intelligent saving of bookmarks and desktop files
+
+(load-config "desktop-conf.el")
+
+(defvar durand-saving-bookmarks nil
+ "Non-nil if we are saving bookmarks already.")
+
+(defun durand-save-bookmark-or-desktop (&optional arg)
+ "Save bookmarks and/or desktop depending on ARG.
+
+If and only if ARG is non-nil, save the desktop file.
+
+If and only if ARG is an integer, do not save bookmarks.
+
+Below are listed three possible scenarios:
+
+1. ARG = nil: save bookmarks only.
+2. ARG = '(4): save both bookmarks and desktop.
+3. ARG = integer: save desktop only."
+ (interactive "P")
+ (cond (arg
+ (let ((durand-saving-bookmarks t))
+ (desktop-save (car desktop-path))
+ (message "desktop saved"))))
+ (cond ((not (integerp arg)) (bookmark-save))))
+
+(define-key ctl-x-r-map (vector ?s) #'durand-save-bookmark-or-desktop)
(provide 'bookmark-conf)
;;; bookmark-conf.el ends here