help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Looking for some recommended configurations for desktop-save-mode and sa


From: Hongyi Zhao
Subject: Looking for some recommended configurations for desktop-save-mode and savehist-mode.
Date: Sun, 17 Jan 2021 12:29:31 +0800

Currently, I noticed the following configurations for
desktop-save-mode and savehist-mode on this website
<https://ebzzry.io/en/emacs-tips-2/>:

---
;Desktop

;An indispensable tool that I use now is desktop. It saves the state
of my Emacs session, so that in the event of crash, power outage, or
anything that will make me lose my session, I can back to it. Desktop
comes built-in with the recent versions of GNU Emacs. Here's my
snippet:
(require 'desktop)

(desktop-save-mode)

(setq desktop-dirname "~/.emacs.d/save"
      desktop-base-file-name "desktop"
      desktop-base-lock-name "desktop.lock"
      desktop-restore-frames t
      desktop-restore-reuses-frames t
      desktop-restore-in-current-display t
      desktop-restore-forces-onscreen t)

(defun desktop-save ()
  (interactive)
  (if (eq (desktop-owner) (emacs-pid))
      (desktop-save desktop-dirname)))

;Savehist

;Another important functionality that I use is savehist. It saves the
minibuffer history. It’s roughly similar to saving the command line
history. Here’s my snippet

(savehist-mode t)

(setq savehist-file "~/.emacs.d/save/savehist")


;Consolidation

;There were a lot of times, when I want to manually save the state of
as much session information that I could save. I’d want to save the
buffers, minibuffer history, bookmarks, and comint mode histories. To
do that, I have the following:

(defun save-defaults ()
  (desktop-save desktop-dirname)
  (savehist-save)
  (bookmark-save))

(defun save-histories ()
  (let ((buf (current-buffer)))
    (save-excursion
      (dolist (b (buffer-list))
        (switch-to-buffer b)
        (save-history)))
    (switch-to-buffer buf)))

(defun save ()
  (interactive)
  (save-desktop)
  (save-defaults)
  (save-histories))

;This gives you a nice:

;M-x save RET
---

This configuration seems a bit cumbersome and lengthy. Is there a
concise similar configuration for this sort of settings? Any
hints/notes/suggestions/configurations are highly appreciated.

Best
-- 
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Polytechnic University of Science and Technology engineering
NO. 552 North Gangtie Road, Xingtai, China



reply via email to

[Prev in Thread] Current Thread [Next in Thread]