From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Hongyi Zhao Newsgroups: gmane.emacs.help Subject: Looking for some recommended configurations for desktop-save-mode and savehist-mode. Date: Sun, 17 Jan 2021 12:29:31 +0800 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19229"; mail-complaints-to="usenet@ciao.gmane.io" To: help-gnu-emacs Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jan 17 05:30:12 2021 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l0zhZ-0004rZ-Iq for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 17 Jan 2021 05:30:09 +0100 Original-Received: from localhost ([::1]:49836 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l0zhY-0007db-K0 for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 16 Jan 2021 23:30:08 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44770) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l0zhD-0007dR-D9 for help-gnu-emacs@gnu.org; Sat, 16 Jan 2021 23:29:47 -0500 Original-Received: from mail-yb1-xb2a.google.com ([2607:f8b0:4864:20::b2a]:43842) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l0zhB-0006qT-KQ for help-gnu-emacs@gnu.org; Sat, 16 Jan 2021 23:29:47 -0500 Original-Received: by mail-yb1-xb2a.google.com with SMTP id y128so9289727ybf.10 for ; Sat, 16 Jan 2021 20:29:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to :content-transfer-encoding; bh=LeKjQRWAHXBRKgA2l6VnN4xdtpr34dQi8IDlRp+stIs=; b=FHs/jF/l4GT32o8wzavPvgDu0fiHnxvMyqEMDXsz5jQknAf3IAP5pdFkPHo7BU7R0o 1kE16JsgHfLircg5Wl3IomGkayZLcWyEV7olhftYQjLiuy9RZjRE9lVyghMMc27eFFAQ Fe8eB2WOanxfAECwdr7bW29bA2cO579xJ7oqi2mJOOzSwCYy3lMdAq40jecG+iBNsL0s 9C93GbSU6/8yMrbgbwNDjX0mKePJi3ViUvdrqu+JKVkA/gE1aUfmxHs4uUYtUFnGnysw jS6WskEFHrl0pOmqQv8VQR1mdkPESzzks2GPTjwavRf9L9LL7YDGpTOHT2dlzreaP11P rYAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to :content-transfer-encoding; bh=LeKjQRWAHXBRKgA2l6VnN4xdtpr34dQi8IDlRp+stIs=; b=Em5wXGOYanhC14HB/DlLVu+0Nn59BhIT1ipiwd+2RpzXS/hwlLf1Z7DV2hG1i2OMxO 1wpwreQfX7W1jFtagcPFiZnVMqA69l6D9SC414PMbqyWc5T7FJsHa6nAcmhKJlKvCkre uCmb9T386RMBGWbC39JSrHtgyyCoVchOcSKpu9rkRTWBdsH3fBp2UVA5Va6v5vt9DS29 tkOqcKEVHFI1Z297pxhSjpjLS2Q3uuOKxvXOtxkYYqvoSHUO7riW+nci5XLuxAlCX5oy WSm2xlKSXsmvRHvOA/5v/zyhwygWibg//Ms4pKi17ahl2Qj0hhs1Wd8FABuuAZAklenb QisA== X-Gm-Message-State: AOAM533bX2G5A1OAfDMGP8jJOlfny4Dc2PUUnz5Dt4ssl9bjktagcOnb RqNmLGoLPwdCcE/N0NUSyjWxhZwTqwM8Uxs7igk72VLVZEpnekx9 X-Google-Smtp-Source: ABdhPJyI2NvtgRzc2vk5UFpG/8JB6V+847IhyICExnoAfCjQq/9GbT2zt3Ed0X7/lvaPzKrL/PieEQmR6kBBMK1P/Q8= X-Received: by 2002:a25:aad1:: with SMTP id t75mr4121616ybi.374.1610857783567; Sat, 16 Jan 2021 20:29:43 -0800 (PST) Received-SPF: pass client-ip=2607:f8b0:4864:20::b2a; envelope-from=hongyi.zhao@gmail.com; helo=mail-yb1-xb2a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:127281 Archived-At: Currently, I noticed the following configurations for desktop-save-mode and savehist-mode on this website : --- ;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=E2=80=99s roughly similar to saving the command line history. Here=E2=80=99s 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=E2=80=99d 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 --=20 Assoc. Prof. Hongyi Zhao Theory and Simulation of Materials Hebei Polytechnic University of Science and Technology engineering NO. 552 North Gangtie Road, Xingtai, China