Bad-ptr / persp-mode.el

named perspectives(set of buffers/window configs) for emacs
394 stars 44 forks source link

persp-mode: Error: Can not autoresume perspectives -- (error Buffer is not associated with any file #133

Closed gutofarias closed 1 year ago

gutofarias commented 1 year ago

Hello,

Sometimes when I shutdown emacs and fire it up again I get some errors like this and my perspectives ares gone:

Error: Can not autoresume perspectives -- (error Buffer is not associated with any file xxxxxxx )

As the error says, the problem is that for some pre-existing buffer in the saved perspective there is not anymore a file to the buffer to load from.

This seems like it should have a simple fix, IF THE FILE IS GONE, KILL THE BUFFER! But I did not find how to configure persp-mode to behave like that. Is there a variable to set this up, or it just works like this?

For me its being a huge pain because everytime close and open emacs I have to open the persp-auto-save file and exclude the buffers that were causing problem.

Cordially, João Gutemberg

Bad-ptr commented 1 year ago

Can you provide an example scenario with as simple steps as possible to reproduce ? Or a sample saved perspectives state file?

Also try the lastest version on develop branch.

gutofarias commented 1 year ago

It is easy to reproduce, just add a buffer to a persp, for example a buffer from a pdf file. Then delete the pdf file and close emacs (C-x C-c). When you open emacs again, (if it is like me) your persps are half gone or some are lacking, and you got those messages:

[persp-mode] Warning: The file /Users/guto/Downloads/-B-I.pdf no longer exists. [persp-mode] Error: Can not autoresume perspectives -- (error Buffer is not associated with any file :-B-I.pdf)

Looks like by the time it gets this error, it stops to rebuilding the other persps.

I will try to update it from MELPA and se if the error persists.

gutofarias commented 1 year ago

The problem persists with this version: persp-mode 20220507.32 installed
I think is the more up-to-date I can get from MELPA

Bad-ptr commented 1 year ago

for example a buffer from a pdf file

Hmm... So it looks like pdf -mode specific. Because I tried to restore perspectives with a text file missing and it went well. OK

I will try to update it from MELPA and se if the error persists.

Actually i want you to download this: https://raw.githubusercontent.com/Bad-ptr/persp-mode.el/develop/persp-mode.el Then in emacs M-x package-install-file RET /path/where/you/saved/persp-mode.el. And try to reproduce the bug after that.

gutofarias commented 1 year ago

The problem seems to remain. I did what you told and tested again with a pdf file.. Same error. Is there a variable with the version so that I can test if I done the installation correctly. Did I need to delete the previous persp-mode?

Bad-ptr commented 1 year ago

Did I need to delete the previous persp-mode?

Looks like yes, it may be necessary to do. And now you may have two packages installed the one from melpa and one from manual installation. Delete both.

Then download the new version https://raw.githubusercontent.com/Bad-ptr/persp-mode.el/develop/persp-mode.el and install

gutofarias commented 1 year ago

Now it worked!!!

I got some errors that I wasn't getting about some other files, but the perspectives were load correctly. The pdf remained a buffer but an empty one! So the pdf problem is resolved! I think it would be better still if the buffer were killed, but you are the author and know best.

I got the following errors, but when I checked all the buffers were correctly load. So I did not understand why the errors happened. I don't remember them happening before.

[persp-mode] Error details: (def-buffer Cargo.toml • quickreplace /Users/guto/Sync/Projetos/Rust/quickreplace/Cargo.toml conf-toml-mode) [persp-mode] Error: persp-buffer-from-savelist failed to restore a buffer -- (wrong-type-argument stringp Cargo.toml) [persp-mode] Error details: (def-buffer main.rs • quickreplace /Users/guto/Sync/Projetos/Rust/quickreplace/src/main.rs rustic-mode) [persp-mode] Error: persp-buffer-from-savelist failed to restore a buffer -- (wrong-type-argument stringp main.rs) [persp-mode] Error details: (def-buffer cli.rs • hello /Users/guto/Sync/Projetos/Rust/Command-Line Rust/hello/tests/cli.rs rustic-mode) [persp-mode] Error: persp-buffer-from-savelist failed to restore a buffer -- (wrong-type-argument stringp cli.rs) [persp-mode] Error details: (def-buffer lib.rs • catr /Users/guto/Sync/Projetos/Rust/Command-Line Rust/catr/src/lib.rs rustic-mode) [persp-mode] Error: persp-buffer-from-savelist failed to restore a buffer -- (wrong-type-argument stringp lib.rs)

Bad-ptr commented 1 year ago

I think it would be better still if the buffer were killed

They are left as empty buffers to not break saved window configurations.

I got the following errors [persp-mode] Error details: (def-buffer Cargo.toml • quickreplace /Users/guto/Sync/Projetos/Rust/quickreplace/Cargo.toml conf-toml-mode) [persp-mode] Error: persp-buffer-from-savelist failed to restore a buffer -- (wrong-type-argument stringp Cargo.toml)

Very strange. Can you open ~/.emacs.d/persp-confs/persp-auto-save, find that (def-buffer Cargo.toml...) and paste it here? Does it have double quotes " around buffer name and file name (like "Cargo.toml")?

gutofarias commented 1 year ago

persp-auto-save.txt (def-buffer "Cargo.toml • quickreplace"

Bad-ptr commented 1 year ago

Try the new version https://github.com/Bad-ptr/persp-mode.el/raw/develop/persp-mode.el

gutofarias commented 1 year ago

Now everything looks nice! Not a single error! Thank you!!

Bad-ptr commented 1 year ago

Thanks for testing, it merged into master branch now. So you can install persp-mode from melpa after it got updated.