From 6372bfbf10b500ce708a9f0fde8caae67c667d7a Mon Sep 17 00:00:00 2001 From: JSDurand Date: Thu, 24 Nov 2022 14:14:03 +0800 Subject: desktop: save bookmarks while saving desktop * desktop-conf.el (desktop-save-hook): Also save bookmarks while saving the desktop file. --- desktop-conf.el | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/desktop-conf.el b/desktop-conf.el index 4762f42..7478742 100644 --- a/desktop-conf.el +++ b/desktop-conf.el @@ -1,3 +1,31 @@ +;;; desktop-conf.el --- Configure desktop mode -*- lexical-binding: t; -*- + +;; Copyright (C) 2022 Jean Sévère Durand + +;; Author: Jean Sévère Durand +;; Keywords: data, files, internal, maint + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Commentary: + +;; Configure the desktop-mode, which saves caches of Emacs states. + +;;; Code: + +;;; Basic settings + (setq desktop-auto-save-timeout 600) (setq desktop-dirname "/Users/durand/.emacs.d/") (setq desktop-path '("/Users/durand/.emacs.d/")) @@ -10,7 +38,13 @@ (setq desktop-restore-frames nil) (setq desktop-save 'ask-if-new) -;;;###autoload +;;; Also save bookmarks before + +(add-hook 'desktop-save-hook #'bookmark-save) + +;;; Overwrite the saving function + +;; Modify to hard-code the directory to save the desktop file. (defun durand-desktop-save-a (dirname &optional release only-if-changed version) "Save the state of Emacs in a desktop file in directory DIRNAME. Optional argument RELEASE non-nil says we're done with this @@ -32,7 +66,7 @@ file. To upgrade a version 206 file to version 208, call this command explicitly with a prefix argument: \\[universal-argument] \\[desktop-save]. -If you are upgrading from Emacs 24 or older, we recommed to do +If you are upgrading from Emacs 24 or older, we recommend to do this once you decide you no longer need compatibility with versions of Emacs before 25.1. @@ -166,5 +200,10 @@ no questions asked." (advice-add 'desktop-save :override 'durand-desktop-save-a) +;;; Enable the mode (desktop-save-mode 1) + + +(provide 'desktop-conf) +;;; desktop-conf.el ends here -- cgit v1.2.3-18-g5258