all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Hongyi Zhao <hongyi.zhao@gmail.com>
To: help-gnu-emacs <help-gnu-emacs@gnu.org>
Subject: Looking for some recommended configurations for desktop-save-mode and savehist-mode.
Date: Sun, 17 Jan 2021 12:29:31 +0800	[thread overview]
Message-ID: <CAGP6POLu+6Ecdj994q24z-SWj6JXsijx7wwoNhA225W=Vi_ghg@mail.gmail.com> (raw)

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	other threads:[~2021-01-17  4:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-17  4:29 Hongyi Zhao [this message]
2021-01-17  8:52 ` Looking for some recommended configurations for desktop-save-mode and savehist-mode 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAGP6POLu+6Ecdj994q24z-SWj6JXsijx7wwoNhA225W=Vi_ghg@mail.gmail.com' \
    --to=hongyi.zhao@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.