reddit / emacs

session manager

zsome · 2022-11-15 15:27
Hi, can you recommend me a session manager what can save / open buffers without a file (I just open a buffer write something down, don't save it) like notepad++ ... I know the editor save it somewhere but I don't want to bother about it.
xskander · 2022-11-15 16:08
I'm pretty new to emacs so i have no idea if this is what you need but you can try this out `(defun xah-new-empty-buffer () (interactive) (let (($buf (generate-new-buffer "untitled"))) (switch-to-buffer $buf) (funcall initial-major-mode) (setq buffer-offer-save t) $buf ))` I don't even know how to format this correctly. But if you bind that function to a keybinding. `(global-set-key (kbd "C-x n") 'xah-new-empty-buffer)` You can now open an empty buffer and add whatever you want to it. Pretty straight forward. I honestly don't remember where i got this method from. But i use it for more or less the same thing you describe. You can just kill it once you're done with it. Hope it helps.
janoc · 2022-11-15 16:37
That's not quite a session manager (that's what desktop mode is for) but you probably want `persistent-scratch`: https://github.com/Fanael/persistent-scratch
akirakom · 2022-11-15 18:22
An alternative way to implement a similar feature would be to set initial-buffer-choice to a file and then turn on some auto saving mode.
SoTypicalNoob · 2022-11-15 19:39
Actually, Notepad++ also use a file to store your "session". (All open tabs and their content.) I use Doom Emacs, and it has an in-built feature for this: https://github.com/doomemacs/doomemacs/blob/7e50f239c46ea17429f159fb543c0d793543c06e/modules/ui/workspaces/README.org#session-persistence Not sure, if this is part of vanilla Emacs, but I'm pretty sure, that you can use this or a similar functionality.
Thaodan · 2022-11-15 20:50
One option that I saw someone writing for elfeed was to add support for the desktop package. Something similar might work here too.
getpoked · 2022-11-16 03:43
just don't close emacs!
zsome · 2022-11-16 06:01
Hi, I've a prepared one from this. But I would like to avoid the lot of unnecessary files in a temporary folder ... Maybe the workgroup2 with the serializer would be a better way :)
zsome · 2022-11-16 06:04
Yes I did it, when I open a "newbuff" (based on xah newbuff) then I create a file in to a folder and set the auto save ... I just would like to avoid a lot of empty or unnecessary files in this buffer.
akirakom · 2022-11-16 06:43
You can also use `midnight-mode` to kill scratch buffers. By adding a function to `midnight-hook`, it can also clean up garbage files.