{"action":"created","issue":{"url":"https://api.github.com/repos/Bad-ptr/persp-mode.el/issues/26","labels_url":"https://api.github.com/repos/Bad-ptr/persp-mode.el/issues/26/labels{/name}","comments_url":"https://api.github.com/repos/Bad-ptr/persp-mode.el/issues/26/comments","events_url":"https://api.github.com/repos/Bad-ptr/persp-mode.el/issues/26/events","html_url":"https://github.com/Bad-ptr/persp-mode.el/issues/26","id":129115805,"number":26,"title":"Switching perspectives misbehaving when a window is dedicated","user":{"login":"bmag","id":4334375,"avatar_url":"https://avatars.githubusercontent.com/u/4334375?v=3","gravatar_id":"","url":"https://api.github.com/users/bmag","html_url":"https://github.com/bmag","followers_url":"https://api.github.com/users/bmag/followers","following_url":"https://api.github.com/users/bmag/following{/other_user}","gists_url":"https://api.github.com/users/bmag/gists{/gist_id}","starred_url":"https://api.github.com/users/bmag/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bmag/subscriptions","organizations_url":"https://api.github.com/users/bmag/orgs","repos_url":"https://api.github.com/users/bmag/repos","events_url":"https://api.github.com/users/bmag/events{/privacy}","received_events_url":"https://api.github.com/users/bmag/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-01-27T11:29:13Z","updated_at":"2016-01-27T17:07:49Z","closed_at":null,"body":"Invoking `persp-switch` (`C-c p s`) from a dedicated window results in a wrong window configuration after perspective is switched. This seems to be a problem with calling `window-state-put` when the current window is a dedicated window, similar to https://github.com/wasamasa/eyebrowse/issues/36\r\n\r\nFor example, consider [neotree](https://github.com/jaypei/emacs-neotree). When I open neotree, neotree creates a dedicated window and selects it. If I then switch to a different perspective, then neotree's window remains visible and the original window configuration of the perspective is ruined. More details in the reproduction recipes.\r\n\r\nAdding `(set-window-dedicated-p nil nil)` right after `(delete-other-windows)` [here](https://github.com/Bad-ptr/persp-mode.el/blob/0987b5ba7d3d27137673f9eead84a6d9edcfd643/persp-mode.el#L1461) seems to fix the error described in recipe 2.\r\n\r\n---\r\n\r\nRecipe 1: creating a new perspective when current window is dedicated:\r\n\r\n1. start emacs: `emacs -Q -l /path/to/persp-mode.el`\r\n2. disable auto-resume: `M-: (setq persp-auto-resume-time -1)`\r\n3. activate persp-mode: `M-x persp-mode`\r\n4. switch to a new buffer: `C-x b foo`\r\n5. make window dedicated: `M-: (set-window-dedicated-p nil t)`\r\n6. switch to a new perspective: `C-c p s bar`\r\n\r\nObserved result: new perspective is created, the frame has two windows: one for buffer `foo` and one for the scratch buffer.\r\n\r\nExpected result: new perspective is created, the frame has one window: for the scratch buffer. The buffer `foo` is not visible.\r\n\r\n---\r\n\r\nRecipe 2: switching to an existing perspective when current window is dedicated:\r\n\r\n1. start emacs: `emacs -Q -l /path/to/persp-mode.el`\r\n2. disable auto-resume: `M-: (setq persp-auto-resume-time -1)`\r\n3. activate persp-mode: `M-x persp-mode`\r\n4. switch to a new perspective: `C-c p s bar`\r\n5. switch to a new buffer: `C-c p s baz`\r\n6. switch back to previous perspective: `C-c p s none`\r\n7. switch to a new buffer: `C-x b foo`\r\n8. make window dedicated: `M-: (set-window-dedicated-p nil t)`\r\n9. switch to the other perspective: `C-c p s bar`\r\n\r\nObserved result: current perspective is now `bar`, but the displayed buffer remains `foo`. The echo area shows the message \"Window is dedicated to \\`foo'\".\r\nIn the `*Messages*` buffer: \"window-state-put: Window is dedicated to \\`foo'\"\r\n\r\nExpected result: current perspective is now `bar`, the displayed buffer is `baz`.\r\n"},"comment":{"url":"https://api.github.com/repos/Bad-ptr/persp-mode.el/issues/comments/175749225","html_url":"https://github.com/Bad-ptr/persp-mode.el/issues/26#issuecomment-175749225","issue_url":"https://api.github.com/repos/Bad-ptr/persp-mode.el/issues/26","id":175749225,"user":{"login":"Bad-ptr","id":1390817,"avatar_url":"https://avatars.githubusercontent.com/u/1390817?v=3","gravatar_id":"","url":"https://api.github.com/users/Bad-ptr","html_url":"https://github.com/Bad-ptr","followers_url":"https://api.github.com/users/Bad-ptr/followers","following_url":"https://api.github.com/users/Bad-ptr/following{/other_user}","gists_url":"https://api.github.com/users/Bad-ptr/gists{/gist_id}","starred_url":"https://api.github.com/users/Bad-ptr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Bad-ptr/subscriptions","organizations_url":"https://api.github.com/users/Bad-ptr/orgs","repos_url":"https://api.github.com/users/Bad-ptr/repos","events_url":"https://api.github.com/users/Bad-ptr/events{/privacy}","received_events_url":"https://api.github.com/users/Bad-ptr/received_events","type":"User","site_admin":false},"created_at":"2016-01-27T17:07:49Z","updated_at":"2016-01-27T17:07:49Z","body":"uhu. Looks like we must store the dedicated window list, and undedicate/rededicate windows when switching."}}