Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPC bb and some others stop working when desktop-mode is enabled #2626

Closed
avendael opened this issue Aug 12, 2015 · 20 comments
Closed

SPC bb and some others stop working when desktop-mode is enabled #2626

avendael opened this issue Aug 12, 2015 · 20 comments
Labels

Comments

@avendael
Copy link
Contributor

For some reason, SPC bb to switch buffers stop working when desktop-mode is enabled. C-x b also has the same problem.

mapcar: Wrong type argument: bufferp, "Unprintable entity"

When I remove these lines from my config, it works fine:

  (desktop-save-mode t)
  (desktop-read)
@bmag
Copy link
Contributor

bmag commented Aug 17, 2015

Could you toggle debugging on with SPC t D (or M-x toggle-debug-on-error), execute SPC b b and paste the backtrace here? That should help us identify the source of the problem.

@TheBB
Copy link
Contributor

TheBB commented Oct 28, 2015

No response from @avendael.

@TheBB TheBB closed this as completed Oct 28, 2015
@karmajunkie
Copy link

I'm seeing this issue, but when I turn on debugging I don't get the debugger activated. Curiously, after I turned on the debugger, the error message went from Wrong-type-argument: bufferp, "Unprintable entity" to Wrong-type-argument: hash-table-p, "Unprintable entity".

I'm not well-versed enough in emacs to figure out what the problem is, but when I run M-x ido-switch-buffer it elicits the problem. I wrote my desktop using M-x desktop-save-in-desktop-dir, and read it back in manually with M-x desktop-read (manually, in other words).

@karmajunkie
Copy link

Also worth mentioning is that helm-projectile-switch-to-buffer is still working. I'm using that to work around the issue by remapping my buffer key to that in the spacemacs file.

@bmag
Copy link
Contributor

bmag commented Dec 16, 2015

@karmajunkie thanks for the info. Seems that desktop-read loads some previously saved state that isn't handled well in helm-mini (or other commands).

We need to identify the offending part in the desktop file - possibly the string "Unprintable entity" appears where a buffer should be. @karmajunkie can you upload the offending desktop file?

We should also identify which Helm source throws the error. Can you try the following commands and report which ones throw an error?

  • M-x helm-mini
  • M-x helm-buffers-list
  • M-x helm-recentf

About the debugging, there should be a buffer named *Backtrace* containing the backtrace. You can switch to it manually and then copy the backtrace.

@karmajunkie
Copy link

M-x helm-mini and M-x helm-buffers-list both throw errors, but M-x helm-recentf successfully pulls up the recent files list. However, the Backtrace buffer is empty, even though I've toggled the debugger on with SPC t D.

@TheBB I'm happy to submit it but its got some file references in it i'm not comfortable submitting, as they point to proprietary data and code. Can I email it to you?

@karmajunkie
Copy link

Looking at the desktop file itself, I do see a lot of "Unprintable entity" references in it. Possibly the bug is in the persistence of the desktop?

@karmajunkie
Copy link

@TheBB Actually I was able to reproduce the problem with a minimal desktop file... To produce this, I updated to the latest version, updated the layers I have configured, restarting, then using desktop-save-in-desktop-dir to write the saved file. I've removed a number of files from the recent files list, but I've verified that I'm still seeing the problem when I open a new emacs session and read in the old desktop with desktop-read. I've attached both the minimal desktop file and my .spacemacs configuration file for your reference.

emacs-minimal.desktop.txt
spacemacs.txt

@bmag
Copy link
Contributor

bmag commented Dec 17, 2015

Thanks for the desktop file, it is very helpful. I can see that all the Unprintable Entities are related to frame parameters that are set by perspective.el:

(setq desktop-saved-frameset
      (vector 'frameset 1
              ;; ... omitted ...
              (list
               (list
                (list
                 ;; ... omitted ...
                 (desktop-list* 'persp-curr
                                ;; this is a perspective struct
                                (vector 'cl-struct-perspective "@spacemacs"
                                        ;; this is supposed to be a list of a buffers
                                        '("unprintable entity")
                                        t nil nil
                                        ;; this is supposed to be a window configuration object
                                        "unprintable entity"
                                        (let
                                            ((mk
                                              (make-marker)))
                                          (add-hook 'desktop-delay-hook
                                                    `(lambda nil
                                                       (set-marker ,mk ,nil
                                                                   (get-buffer ," *temp*"))))
                                          mk)))
                 ;; this is supposed to be a hash table mapping perspective names to perspective structures
                 '(perspectives-hash . "unprintable entity")
                 ;; ... omitted ...
                 )
                ;; ... omitted ...
                ))))

Buffers, window configurations (as returned by current-window-configuration) and hash tables are not supported as writable/restorable values by desktop.el. The "Unprintable entity" is the value that is saved instead of the actual buffer/window-configuration/hash-table object. This is implemented in desktop--v2s, which is called in order to save the frame parameters (and other non-related variables).

When you call desktop-read, I presume that it overwrites perspective's frame parameters, because of the problematic desktop file. Somehow these values get loaded in the current perspective (maybe not immediately). Then SPC b b triggers some code in perspective that receives a "Unprintable entity" string instead of a buffer, and throws an error. However, I could not verify this theory as I wasn't able to reproduce a problematic desktop file.

I don't know how to solve the problem yet, but I see two ways to solve this:

  • Prevent writing the offending frame parameters to file. Possibly requires a change in perspective.el, perhaps need to add to desktop-save-hook a hook similar to powerline-desktop-save-delete-cache. I think this will be the easier solution and the more correct solution.
  • Allow writing the offending frame parameters, but don't load them, or prevent the loading process from overwriting perpective's state. I think is will be a harder solution and not the correct one.
  • Change the loading order on the user-side or Spacemacs-side, so the desktop file is read before perspective is loaded. This may cause other problems, because maybe the buffers loaded by the desktop file won't have all the configuration/modes that the user/Spacemacs configures for them.

It is important to note that this is a problem involving perspective.el, but in develop branch (and version 0.105 when its released) we have switched to persp-mode.el. I don't know if persp-mode has this problem or not, so this bug might be solved in develop branch.

What you can do in the meantime:

  • continue using ido-switch-buffer
  • don't use perspectives layer, or don't use desktop.el
  • switch to develop and see if it helps. You will need to update your config because of changes that were made in develop. Looking at your dotfile, it could take some effort, so it's up to you to decide.
  • try using desktop-save-hook

I'll try to find time during the next week to investigate further, but I may be too busy.

P.S. I'm bmag, you were mistakenly pinging TheBB

@karmajunkie
Copy link

@bmag thanks for the detailed analysis! Is there a resource about what's changed in the develop branch I could look to for an update of my config file? If this is something that's a non-issue in an upcoming release because of the change to persp-mode I imagine I can muddle along in the meantime, depending on how long that's likely to be. I'm mostly trying to replicate the functionality of :mksession in vim, as I switch between perspectives quite frequently (at least one per project, and I change projects a few times a day)

@TheBB sorry for the spurious mentions :) This is the last one!

@TheBB
Copy link
Contributor

TheBB commented Dec 18, 2015

Doesn't matter, I get e-mails for everything in this repo anyway.

@bmag
Copy link
Contributor

bmag commented Dec 19, 2015

@karmajunkie quite a lot has changed. Regarding perspective, this PR rewrote the perspective layer, and there were a few changes after that. The layer is called spacemacs-layouts now, and is enabled by default if you use the spacemacs distribution (as opposed to spacemacs-base). You can look at its documentation here. You can also do a diff between your dotspacemacs and the default template that's in develop. Usually the changelog is updated a short time before a new release, but I see that it isn't updated yet for 0.105. I don't know when the next release is, but I think @syl20bnr said it could be in time for Christmas.

@rpglover64
Copy link
Contributor

Can we reopen this bug? It doesn't seem to have been resolved, and I just ran into it on Spacemacs v.0.105.14.

@bmag
Copy link
Contributor

bmag commented Apr 1, 2016

@rpglover64 can you share your desktop file, along with the output of SPC h d s and how you configured desktop mode? The desktop file should be at ~/.emacs.d/.cache/.emacs.desktop.
If you can provide a recipe as to how to produce a problematic desktop file, that would also help.

As a side note, spacemacs will automatically save your session and restore it on startup if you set dotspacemacs-auto-resume-layouts to t. You may be able to use that instead of desktop mode.

@rpglover64
Copy link
Contributor

I actually did what @karmajunkie did:

I wrote my desktop using M-x desktop-save-in-desktop-dir, and read it back in manually with M-x desktop-read (manually, in other words).

I don't normally want to resume layouts, so I don't turn on auto-resume

Output of SPC h d s:

System Info

  • OS: gnu/linux
  • Emacs: 24.5.1
  • Spacemacs: 0.105.14
  • Spacemacs branch: master (rev. 3aff734)
  • Graphic display: t
  • Distribution: spacemacs
  • Editing style: vim
  • Completion: helm
  • Layers:
(auto-completion deft better-defaults emacs-lisp markdown
                 (org :variables org-enable-github-support t)
                 spell-checking
                 (syntax-checking :variables syntax-checking-enable-tooltips nil)
                 version-control markdown emacs-lisp
                 (latex :variables latex-enable-auto-fill nil latex-build-command "Rubber")
                 (haskell :variables haskell-enable-ghci-ng-support t)
                 (git :variables git-magit-status-fullscreen t git-gutter-use-fringe t)
                 github
                 (evil-snipe :variables evil-snipe-enable-alternate-f-and-t-behaviors t)
                 ov ocaml hide-region unicode-fonts finance command-log speed-reading liquid-types eyebrowse mu4e)

backtrace:

Debugger entered--Lisp error: (wrong-type-argument bufferp "Unprintable entity")
  buffer-name("Unprintable entity")
  mapcar(buffer-name (#<buffer grading comments.org> #<buffer save-and-commit-comments.org> "Unprintable entity" "Unprintable entity" "Unprintable entity" "Unprintable entity" "Unprintable entity" "Unprintable entity" "Unprintable entity" "Unprintable entity" "Unprintable entity" "Unprintable entity" "Unprintable entity" "Unprintable entity" "Unprintable entity" "Unprintable entity" "Unprintable entity" "Unprintable entity" "Unprintable entity" "Unprintable entity" "Unprintable entity" "Unprintable entity" "Unprintable entity" "Unprintable entity" "Unprintable entity" "Unprintable entity" "Unprintable entity" "Unprintable entity" "Unprintable entity" "Unprintable entity" "Unprintable entity" "Unprintable entity" "Unprintable entity" "Unprintable entity"))
  persp-restrict-ido-buffers()
  run-hooks(ido-make-buffer-list-hook)
  ido-make-buffer-list(nil)
  helm-buffer-list()
  helm-buffers-list--init()
  apply(helm-buffers-list--init nil)
  helm-funcall-with-source(((name . "Buffers") (init . helm-buffers-list--init) (candidates . helm-buffers-list-cache) (keymap keymap (29 . helm-toggle-buffers-details) (24 keymap (19 . helm-buffer-save-persistent)) (67108925 . helm-buffer-diff-persistent) (3 keymap (97 . helm-buffers-toggle-show-hidden-buffers) (100 . helm-buffer-run-kill-persistent) (61 . helm-buffer-run-ediff) (15 . helm-buffer-switch-other-frame) (111 . helm-buffer-switch-other-window)) (19 . helm-buffers-run-multi-occur) (27 keymap (67108896 . helm-buffers-mark-similar-buffers) (97 . helm-mark-all) (109 . helm-toggle-all-marks) (37 . helm-buffer-run-query-replace) (67108901 . helm-buffer-run-query-replace-regexp) (68 . helm-buffer-run-kill-buffers) (85 . helm-buffer-revert-persistent) (61 . helm-buffer-run-ediff-merge) (103 keymap (115 . helm-buffer-run-zgrep))) keymap (tab . helm-execute-persistent-action) (33554440 . describe-key) (17 . ace-jump-helm-line) (f13 lambda nil (interactive) (helm-select-nth-action 12)) (f12 lambda nil (interactive) (helm-select-nth-action 11)) (f11 lambda nil (interactive) (helm-select-nth-action 10)) (f10 lambda nil (interactive) (helm-select-nth-action 9)) (f9 lambda nil (interactive) (helm-select-nth-action 8)) (f8 lambda nil (interactive) (helm-select-nth-action 7)) (f7 lambda nil (interactive) (helm-select-nth-action 6)) (f6 lambda nil (interactive) (helm-select-nth-action 5)) (f5 lambda nil (interactive) (helm-select-nth-action 4)) (f4 lambda nil (interactive) (helm-select-nth-action 3)) (f3 lambda nil (interactive) (helm-select-nth-action 2)) (f2 lambda nil (interactive) (helm-select-nth-action 1)) (menu-bar keymap (help-menu keymap (describe keymap (describe-mode . helm-help)))) (help keymap (109 . helm-help)) (f1 lambda nil (interactive) (helm-select-nth-action 0)) (8 . helm-next-source) (20 . helm-toggle-resplit-and-swap-windows) (C-tab . undefined) (67108897 . helm-toggle-suspend-update) (3 keymap (57 lambda nil (interactive) (helm-execute-selection-action-at-nth 9)) (56 lambda nil (interactive) (helm-execute-selection-action-at-nth 8)) (55 lambda nil (interactive) (helm-execute-selection-action-at-nth 7)) (54 lambda nil (interactive) (helm-execute-selection-action-at-nth 6)) (53 lambda nil (interactive) (helm-execute-selection-action-at-nth 5)) (52 lambda nil (interactive) (helm-execute-selection-action-at-nth 4)) (51 lambda nil (interactive) (helm-execute-selection-action-at-nth 3)) (50 lambda nil (interactive) (helm-execute-selection-action-at-nth 2)) (49 lambda nil (interactive) (helm-execute-selection-action-at-nth 1)) (63 . helm-help) (62 . helm-toggle-truncate-line) (21 . helm-refresh) (6 . helm-follow-mode) (9 . helm-copy-to-buffer) (11 . helm-kill-selection-and-quit) (25 . helm-yank-selection) (45 . helm-swap-windows)) (67108987 . helm-enlarge-window) (67108989 . helm-narrow-window) (19 . undefined) (18 . undefined) (23 . helm-yank-text-at-point) (24 keymap (57 lambda nil (interactive) (helm-execute-selection-action-at-nth -9)) (56 lambda nil (interactive) (helm-execute-selection-action-at-nth -8)) (55 lambda nil (interactive) (helm-execute-selection-action-at-nth -7)) (54 lambda nil (interactive) (helm-execute-selection-action-at-nth -6)) (53 lambda nil (interactive) (helm-execute-selection-action-at-nth -5)) (52 lambda nil (interactive) (helm-execute-selection-action-at-nth -4)) (51 lambda nil (interactive) (helm-execute-selection-action-at-nth -3)) (50 lambda nil (interactive) (helm-execute-selection-action-at-nth -2)) (49 lambda nil (interactive) (helm-execute-selection-action-at-nth -1)) (2 . helm-resume-list-buffers-after-quit) (98 . helm-resume-previous-session-after-quit) (6 . helm-quit-and-find-file)) (11 . helm-previous-line) (67108896 . helm-toggle-visible-mark) (0 . helm-toggle-visible-mark) (C-M-up . helm-scroll-other-window-down) (C-M-down . helm-scroll-other-window) (M-prior . helm-scroll-other-window-down) (M-next . helm-scroll-other-window) (12 . "
") (15 . helm-next-source) (10 . helm-next-line) (26 . helm-select-action) (9 . helm-execute-persistent-action) ...) (action . helm-type-buffer-actions) (persistent-action . helm-buffers-list-persistent-action) (persistent-help . "Show this buffer") (help-message . helm-buffer-help-message) (filtered-candidate-transformer helm-skip-boring-buffers helm-buffers-sort-transformer helm-highlight-buffers helm-fuzzy-highlight-matches) (volatile) (match . helm-buffers-match-function) (header-line . "TAB: Show this buffer (keeping session)") (resume lambda nil (run-with-idle-timer 0.1 nil (lambda nil (with-helm-buffer (helm-force-update))))) (dont-plug helm-compile-source--multi-match helm-compile-source--persistent-help helm-compile-source--migemo) (migemo . nomultimatch) (buffer-list . helm-buffer-list)) helm-buffers-list--init)
  helm-funcall-foreach(init nil)
  helm-initial-setup(nil)
  helm-initialize(nil nil nil (helm-source-buffers-list helm-source-recentf helm-source-buffer-not-found))
  #[0 "\311\211\211\211\305\206\n

I can't provide the desktop file, because I think it may have private (or semiprivate) information in it (e.g. student ids of my students)

I'll try to reproduce when I'm done grading.

One more weird thing happened: when I opened a new frame, SPC b b worked in that frame. It still did not work in the previous one, and neither did C-x b, but C-x C-b (bound to ibuffer) did.

Possibly relevant to reproducing the bug: I was in a layout besides the default one when I saved the desktop file, but the layout does not appear to have been restored.

@bmag
Copy link
Contributor

bmag commented Apr 1, 2016

I can't provide the desktop file, because I think it may have private (or semiprivate) information in it

That's understandable. I'm interested in the part of (setq desktop-saved-frameset ...), if it's safe to share. Does it contain a desktop-list* form somewhere inside? Are the unprintable entities inside that form, or perhaps inside other forms?

I'm not sure what to make of the other parts right now.

@rpglover64
Copy link
Contributor

There is no desktop-list anywhere in the file.
Here's the desktop-saved-frameset (the "unprintable entity"s are inside an alist, as a value whose key is persp):

(setq desktop-saved-frameset
      [frameset 1
                (22269 45168 865510 450000)
                (desktop . "206")
                "alex@zuko" nil nil
                ((((font-backend xft x)
                   (font . "-unknown-Hack-normal-normal-normal-*-13-*-*-*-m-0-iso10646-1")
                   (font-parameter)
                   (border-width . 0)
                   (internal-border-width . 0)
                   (right-divider-width . 0)
                   (bottom-divider-width . 0)
                   (vertical-scroll-bars)
                   (foreground-color . "#657b83")
                   (background-color . "#fdf6e3")
                   (mouse-color . "black")
                   (border-color . "black")
                   (screen-gamma)
                   (line-spacing)
                   (left-fringe . 8)
                   (right-fringe . 8)
                   (scroll-bar-foreground)
                   (scroll-bar-background . "grey75")
                   (menu-bar-lines . 0)
                   (tool-bar-lines . 0)
                   (title)
                   (wait-for-wm . t)
                   (fullscreen)
                   (tool-bar-position . top)
                   (icon-type . t)
                   (auto-raise)
                   (auto-lower)
                   (cursor-type . box)
                   (scroll-bar-width . 0)
                   (cursor-color . "DarkGoldenrod2")
                   (alpha)
                   (display-type . color)
                   (background-mode . light)
                   (persp .
                    [cl-struct-perspective "grading"
                                           ("Unprintable entity" "Unprintable entity" "Unprintable entity" "Unprintable entity" "Unprintable entity" "Unprintable entity" "Unprintable entity" "Unprintable entity" "Unprintable entity" "Unprintable entity" "Unprintable entity" "Unprintable entity" "Unprintable entity" "Unprintable entity" "Unprintable entity" "Unprintable entity" "Unprintable entity" "Unprintable entity" "Unprintable entity" "Unprintable entity" "Unprintable entity" "Unprintable entity" "Unprintable entity" "Unprintable entity" "Unprintable entity" "Unprintable entity" "Unprintable entity" "Unprintable entity" "Unprintable entity" "Unprintable entity" "Unprintable entity" "Unprintable entity")

--- snip ---

(for the full file: https://gist.github.com/rpglover64/e61d339facaa70efdb7f4ffcc8a52aa2)

@bmag
Copy link
Contributor

bmag commented Apr 2, 2016

@rpglover64 please check if adding the following to user-config or user-init helps:

(push '(persp . :never) frameset-filter-alist)

This code should prevent the persp entry from being saved or restored, and of course needs to run before loading the desktop file. You should expect a side-effect of perspectives (layouts) not being restored, but hopefully no other perspective-related side-effects.

On develop, and maybe on 0.105.14 as well, It is also possible to save and restore perspectives (layouts) manually via SPC l s (save all), SPC l S (save some) and SPC l L (load from file).

@bleggett
Copy link

bleggett commented Apr 3, 2017

This is still an issue in 0.200.8

@stradicat
Copy link
Contributor

stradicat commented Oct 21, 2017

Problem persists in 0.200.9, as of Oct 21 2017, using Emacs 25.3.2 (kelleyk PPA).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants