* 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
* Re: Looking for some recommended configurations for desktop-save-mode and savehist-mode. 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 0 siblings, 2 replies; 5+ messages in thread From: Tak Kunihiro @ 2021-01-17 8:52 UTC (permalink / raw) To: Hongyi Zhao; +Cc: help-gnu-emacs, tkk > Currently, I noticed the following configurations for > desktop-save-mode and savehist-mode on this website When don't you save desktop when quit emacs? (add-hook 'kill-emacs-hook #'sesame-desktop-save) (defun sesame-desktop-save () "Save desktop anyway." (interactive) (require 'desktop) (setq desktop-dirname user-emacs-directory) (let ((file (desktop-full-file-name))) (when (file-exists-p file) (delete-file file))) (desktop-save (expand-file-name desktop-dirname) t)) ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Looking for some recommended configurations for desktop-save-mode and savehist-mode. 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 1 sibling, 0 replies; 5+ messages in thread From: moasenwood--- via Users list for the GNU Emacs text editor @ 2021-01-17 14:29 UTC (permalink / raw) To: help-gnu-emacs Tak Kunihiro wrote: >> Currently, I noticed the following configurations for >> desktop-save-mode and savehist-mode on this website > > When don't you save desktop when quit emacs? > > (add-hook 'kill-emacs-hook #'sesame-desktop-save) > > (defun sesame-desktop-save () > "Save desktop anyway." > (interactive) > (require 'desktop) > (setq desktop-dirname user-emacs-directory) > (let ((file (desktop-full-file-name))) > (when (file-exists-p file) > (delete-file file))) > (desktop-save (expand-file-name desktop-dirname) t)) But you don't have to delete it to update it, right? I don't use this so I might be wrong but that seems strange one has to do manually. In the docstring to `desktop-save' it says: If ONLY-IF-CHANGED is non-nil, compare the current desktop information to that in the desktop file, and if the desktop information has not changed since it was last saved, then do not rewrite the file. Sounds like it, it me... -- underground experts united http://user.it.uu.se/~embe8573 https://dataswamp.org/~incal ^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: Looking for some recommended configurations for desktop-save-mode and savehist-mode. 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 1 sibling, 1 reply; 5+ messages in thread From: Drew Adams @ 2021-01-17 18:42 UTC (permalink / raw) To: Tak Kunihiro, Hongyi Zhao; +Cc: help-gnu-emacs, tkk Not sure what the original question was, but I'll add this info to the discussion, in case it helps. Besides explicitly or implicitly saving the desktop, you can _bookmark_ a desktop. The vanilla desktop code (desktop.el) doesn't make it easy to have multiple desktop files, and it doesn't provide for more than one desktop file per directory. There's absolutely no reason that a desktop file should be tied to a directory. But that limitation is built into what desktop.el provides and expects. It's a poor design, but it's never been fixed. To bookmark desktops you need Bookmark+. Bookmark+ defines command `bmkp-desktop-read', which loads a desktop file. And command `bmkp-desktop-change-dir', which clears the current desktop and changes to a desktop file you're prompted for. And function `bmkp-desktop-save' saves the current desktop to a given file. Such additions, which facilitate using multiple desktop files are simple and trivial. I've proposed that desktop.el offer the same or similar, but that suggestion and request has fallen on deaf ears. That, in itself, doesn't even have anything to do with bookmarks. Why is it needed? To be able to flexibly create and use multiple desktop files, located anywhere. All that's recorded for a desktop is saved in a file. Hard-code associating that with some directory doesn't help in any way; it's just a hindrance, IMO. A desktop bookmark just records a desktop file. So these desktop enhancements also facilitate having desktop bookmarks. Desktop bookmarks let you switch among desktops by hitting a key - jump among different bookmarks. Emacs desktops can save lots of kinds of state, including buffers (and their points, marks, and local variables), files, windows, frames, and variables. (Bookmark+ also lets you save and restore other bits of state, e.g. sets of variables, by jumping to bookmarks.) https://www.emacswiki.org/emacs/BookmarkPlus https://www.emacswiki.org/emacs/BookmarkPlus#DesktopBookmarks ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Looking for some recommended configurations for desktop-save-mode and savehist-mode. 2021-01-17 18:42 ` Drew Adams @ 2021-01-18 3:25 ` Hongyi Zhao 0 siblings, 0 replies; 5+ messages in thread From: Hongyi Zhao @ 2021-01-18 3:25 UTC (permalink / raw) To: Drew Adams; +Cc: Tak Kunihiro, tkk, help-gnu-emacs On Mon, Jan 18, 2021 at 2:44 AM Drew Adams <drew.adams@oracle.com> wrote: > > Not sure what the original question was, but > I'll add this info to the discussion, in case > it helps. > > Besides explicitly or implicitly saving the > desktop, you can _bookmark_ a desktop. > > The vanilla desktop code (desktop.el) doesn't > make it easy to have multiple desktop files, > and it doesn't provide for more than one > desktop file per directory. > > There's absolutely no reason that a desktop > file should be tied to a directory. But that > limitation is built into what desktop.el > provides and expects. It's a poor design, > but it's never been fixed. > > To bookmark desktops you need Bookmark+. > > Bookmark+ defines command `bmkp-desktop-read', > which loads a desktop file. And command > `bmkp-desktop-change-dir', which clears the > current desktop and changes to a desktop file > you're prompted for. And function > `bmkp-desktop-save' saves the current desktop > to a given file. > > Such additions, which facilitate using > multiple desktop files are simple and trivial. > I've proposed that desktop.el offer the same > or similar, but that suggestion and request > has fallen on deaf ears. > > That, in itself, doesn't even have anything > to do with bookmarks. Why is it needed? To > be able to flexibly create and use multiple > desktop files, located anywhere. > > All that's recorded for a desktop is saved > in a file. Hard-code associating that with > some directory doesn't help in any way; it's > just a hindrance, IMO. > > A desktop bookmark just records a desktop > file. So these desktop enhancements also > facilitate having desktop bookmarks. > > Desktop bookmarks let you switch among > desktops by hitting a key - jump among > different bookmarks. > > Emacs desktops can save lots of kinds of > state, including buffers (and their points, > marks, and local variables), files, windows, > frames, and variables. > > (Bookmark+ also lets you save and restore > other bits of state, e.g. sets of variables, > by jumping to bookmarks.) > > https://www.emacswiki.org/emacs/BookmarkPlus > > https://www.emacswiki.org/emacs/BookmarkPlus#DesktopBookmarks Thank you so much for letting me know this. Best regards, -- 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
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.