unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Looking for some recommended configurations for desktop-save-mode and savehist-mode.
@ 2021-01-17  4:29 Hongyi Zhao
  2021-01-17  8:52 ` Tak Kunihiro
  0 siblings, 1 reply; 5+ messages in thread
From: Hongyi Zhao @ 2021-01-17  4:29 UTC (permalink / raw)
  To: help-gnu-emacs

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



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-01-18  3:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-17  4:29 Looking for some recommended configurations for desktop-save-mode and savehist-mode Hongyi Zhao
2021-01-17  8:52 ` Tak Kunihiro
2021-01-17 14:29   ` moasenwood--- via Users list for the GNU Emacs text editor
2021-01-17 18:42   ` Drew Adams
2021-01-18  3:25     ` Hongyi Zhao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).