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

Split buffer with same file doesn't maintain both positions #114

Open
chipschap opened this issue Mar 4, 2022 · 2 comments
Open

Split buffer with same file doesn't maintain both positions #114

chipschap opened this issue Mar 4, 2022 · 2 comments

Comments

@chipschap
Copy link

chipschap commented Mar 4, 2022

Using workgroups2 from Melpa, Arch Linux, Emacs 27.2, with helm and save-place-mode.

My use case: the same file split into 2 windows, each window at a different position in the file. Save to a workgroup and next time around in Emacs, restore.

The file in question opens in 2 windows as expected but both windows are at the same file position rather than different positions as desired. The windows are in fact open at the save-place-mode saved position, not the workgroups saved position(s).

The cause appears to be that wg-restore-buffer is forced to return nil. This prevents point from being restored up in wg-restore-window. When I change 'nil' to 't' at the bottom of wg-restore-buffer, point is restored (to the two different places) as expected in my split window. (I don't see how point is ever restored at all, in fact, although I'm probably missing something.)

However forcing 't' is crude. The problem is in the 'when' clauses for debugging. A possible rewrite is this:

(defun wg-restore-buffer (buf &optional switch)
"Restore BUF, return it and maybe SWITCH to it."
(when buf
(fset 'buffer-list wg-buffer-list-original)
(cond
((wg-restore-existing-buffer buf switch))
((wg-restore-special-buffer buf switch))
((wg-restore-file-buffer buf switch))
(t
(wg-restore-default-buffer switch)))))

This works fine for me but I'm not familiar enough with workspace2 code to see if there are unintended consequences.

@redguardtoo
Copy link
Collaborator

b4fb228 can restore marker position (Chen Bin)

@chipschap
Copy link
Author

Thank you, a much nicer patch than mine!

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

No branches or pull requests

2 participants