Comments (15)
I switch to use persp-mode, which provides saving and restoring features.
visit https://github.com/Bad-ptr/persp-mode.el.
from perspective-el.
I looked into persp-mode
, but it doesn't play well with projectile (which is part of the reason I'm using perspectives). I'm not interested in using revive
since desktop-save-mode
can restore window configurations.
So I threw together some functionality to save/restore the buffers and perspective names using desktop-save-mode
. I may spend some time figuring out how to save/restore everything else in the persp struct, but this does 99% of what I need.
(defun perspectives-buffer-name-p (buffer)
(if (and buffer
(buffer-name buffer)
(not (string-prefix-p "*" (buffer-name buffer)))
(not (string-suffix-p "*" (buffer-name buffer))))
t
nil))
(defun perspectives-hash-filter (current filtered parameters saving)
(let ((value (cdr current))
(result ())
(keys (hash-table-keys (cdr current))))
;; for every perspective...
(dolist (key keys)
(let ((persp (gethash key value)))
;; that isn't killed...
(if (not (persp-killed persp))
(add-to-list
'result
(cons key
;; save the list of buffers
(list (cons "buffers"
(list
(mapcar 'buffer-name (seq-filter 'perspectives-buffer-name-p (persp-buffers persp)))))))))))
;; return a different variable name so perspectives doesn't clobber it
(cons 'perspectives-hash-serialized result)))
;; serialize perspectives hash
(add-to-list 'frameset-filter-alist '(perspectives-hash . perspectives-hash-filter))
;; don't serialize anything else
(add-to-list 'frameset-filter-alist '(persp-modestring . :never))
(add-to-list 'frameset-filter-alist '(persp-recursive . :never))
(add-to-list 'frameset-filter-alist '(persp-last . :never))
(add-to-list 'frameset-filter-alist '(persp-curr . :never))
(defun perspectives-restore-state ()
(dolist (frame (frame-list))
;; get the serialized state off of the frame
(let ((state (frame-parameter frame 'perspectives-hash-serialized)))
(if state (progn
(message "Found state, attempting restore")
;; delete it so we don't end up in a loop
(set-frame-parameter frame 'perspectives-hash-serialized nil)
(with-selected-frame frame
(dolist (elem state)
;; recreate the perspective
(with-perspective (car elem)
(dolist (buffer-name (car (cdr (assoc "buffers" (cdr elem)))))
;; add the buffer back to the perspective
(persp-add-buffer buffer-name)
)))
))
(message "No state found")
)
)))
(add-hook 'desktop-after-read-hook 'perspectives-restore-state)
from perspective-el.
There's no built-in save/restore mechanism. You could add some code to your .emacs
to create a bunch of perspectives whenever Emacs starts up.
from perspective-el.
Would you like to show me an example how to do this? I really like your approach and I would like to use it. I'm relatively new to Emacs. Hopefully, you can explain what I have too do that I get the last session saved and reloaded every time I restart Emacs. I tried so many other solutions today, yet yours is still the best one.
from perspective-el.
You can just add (persp-new "perspective-name")
for all of the perspectives you want to create.
from perspective-el.
I was just trying to achieve something similar by using desktop-save-mode, but it doesn't work out-of-the-box.
I guess a little extra work is required to restore perspective state, will look into it when I find some time.
from perspective-el.
I took a shot at adding durability support. Please take a look: #80 (or my fork, https://github.com/gcv/perspective-el).
from perspective-el.
This feature is now available as persp-state-save
and persp-state-load
.
from perspective-el.
How can i automaticaly initialize persp-state-load
at starting perspective, such as with persp-state-safe
at emacs-kill
.
from perspective-el.
@JPRuehmann: Please see #200.
from perspective-el.
FYI, you may find this new package interesting. It doesn't do exactly what perspective
does, but it's similar: https://github.com/alphapapa/activities.el
from perspective-el.
Hi @alphapapa! I took a look at Activities. It looks really promising, and it's really nice that it's built on modern Emacs foundations. Perspective is certainly showing its age (first commit in March 2008), and pretty much all open long-lasting tickets result from it. I'll definitely try Activities as a daily driver once switch-to-buffer
filtering arrives (it's something in Perspective I can't live without).
PS: Small correction to the Activities README (where it says "To date, only Burly and Bufler seem to offer the ability to restore one across Emacs sessions"): Perspective does allow saving and loading state, so perspectives can be restored in a new Emacs session. The implementation is less elegant than the bookmarks approach you chose, and probably more limited, but it works well enough.
from perspective-el.
Another great alternative is tabspaces, which is built on the built-in packages: tabbar and project (27.1+). It's simple but flexible.
Tabspaces leverages tab-bar.el and project.el (both built into emacs 27+) to create buffer-isolated workspaces (or “tabspaces”) that also integrate with your version-controlled projects. It should work with emacs 27+. It is tested to work with a single frame workflow, but should work with multiple frames as well.
from perspective-el.
I'll definitely try Activities as a daily driver once
switch-to-buffer
filtering arrives (it's something in Perspective I can't live without).
Understood. Well, I just pushed activities-switch-buffer
. Please see alphapapa/activities.el#43 (comment) and let me know what you think.
from perspective-el.
PS: Small correction to the Activities README (where it says "To date, only Burly and Bufler seem to offer the ability to restore one across Emacs sessions"): Perspective does allow saving and loading state, so perspectives can be restored in a new Emacs session. The implementation is less elegant than the bookmarks approach you chose, and probably more limited, but it works well enough.
Thanks. I've updated it to mention non-file-backed buffers, which seems to be the key distinction. alphapapa/activities.el@80e76f2
from perspective-el.
Related Issues (20)
- Perspective breaks after enable-theme HOT 5
- Perspective hides buffers when running Emacs as server HOT 4
- Current perspective name not being propertized in the mode-line HOT 5
- Display perspective in frame title HOT 7
- `C-x 5 2 ` different behaviour when running perspective with daemon HOT 2
- Perspective.el wipes out perspectives when a emacsclient frame is closed. HOT 2
- `persp-delete-frame` alters windows of other frames when killing frame with dedicated window HOT 1
- Issue with using ediff and perspective [sorted] HOT 6
- Compare to tabspaces? HOT 2
- Support eshell state save and restore
- Would it support different themes per frame? HOT 2
- Loading perspectives upon opening emacs HOT 5
- ibuf-ext.el not loaded HOT 2
- Feature request: Add `perspective-kill-other-buffers` HOT 3
- Perspective is killing lsp-servers when switching between perspective projects. HOT 7
- function to add buffer to persp other than current persp HOT 2
- a new function needed please. HOT 1
- problem with exwm-input-prefix-keys HOT 2
- How can I set a longer prefix key? HOT 1
- Avoid helm dependency? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from perspective-el.