-
Notifications
You must be signed in to change notification settings - Fork 44
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
Fix: (ement-room-list) Prevent window position being set via markers #193
base: master
Are you sure you want to change the base?
Conversation
Any markers in the room list buffer will be set to position 1 when `erase-buffer' is called each time the buffer is rebuilt, which caused the window point to be forcibly moved to the start of the buffer in many situations. See alphapapa#175
Ah, not quite done yet... set-window-point(1): (set-window-point@my-debug apply set-window-point set-window-buffer-start-and-point switch-to-prev-buffer replace-buffer-in-windows kill-buffer funcall-interactively call-interactively command-execute) |
Sigh, this looks like an Emacs bug...
(I've logged a bug report and CC'd you, Adam.) |
Thank you, Phil. This problem was driving me crazy. I'm relieved to know that it's an Emacs bug after all. Could you link the report here please? |
The upstream bug report is https://debbugs.gnu.org/cgi/bugreport.cgi?bug=64911 Were it not for that, I suspect this PR would have been sufficient to resolve the issue entirely. As it is the current code will resolve it partially. I'm sure I can work around the remaining aspects in a similar fashion to what I've done for the Alternatively, at this point I think using (delete-all-overlays)
(erase-buffer)
<generate new contents> with this: (delete-all-overlays)
<generate new contents in newbuffer>
(replace-buffer-contents <newbuffer>)
(kill-buffer <newbuffer>) In principle it's not that simple if the optional MAX-SECS / MAX-COSTS args and behaviours are to be accounted for robustly, but maybe this will be fast enough that we don't need to worry in practice. (That might not be good enough on its own, though. It really depends on how the |
Maybe I'm missing something, but AIUI, the problem is that the window-point stuff uses markers internally, which I didn't realize; I expected that those were using integer positions. So could we work around the problem by recording the point markers' positions and resetting from those (rather than using the actual markers)? It might also be good to save the magit-section identity before erasing the buffer and try to go back to the same section after updating the buffer, if it's still present, and then fall back to positions. |
Yes indeed -- and in fact I've done exactly that in the most recent commit.
Yep, I'd noted your |
Thanks. A final question, then: Do we still need to walk the windows and do things with their markers, or can we just record the marker positions for the room list window and use that? |
We do still need to capture and reposition the markers, because we're not in control of the code which uses them to set the window point (in certain scenarios). So we need to ensure that the markers are positioned the way we want them, otherwise they'll still wind up being back at position 1 when that other code uses them. |
Can you confirm whether the pre-existing I was just failing to make the related change to my code, and when I test the following interactively I get
|
I think I was missing the fact that the section identifier varies with the hierarchical structure, so when a room moves from, say, "Unspaced" to "Buffer" its ID has different I see I can obtain room IDs at a position like so:
What would be the most efficient way to do the inverse -- locate a line in the room list buffer based on a room ID? |
This may be relevant:
e.g. |
a68abe0
to
9da7b8e
Compare
Regarding that, this commit I merged changes the section idents from pointing to the actual room and session structs to using just their ID strings: 2764c10 |
@phil-s I'm tidying up the list of issues for the v0.15 release. Do you think this should be merged for v0.15 or deferred for v0.16? (I generally try to keep down the number of changes that might introduce unexpected breakage, including ones I don't understand well.) |
Let's leave this for now. By accident it's ended up not being one of the patches I've been running locally, so I've not tested it recently and I don't want to have to review it at the moment. |
Sure, I'll mark it for v0.16 then. Thanks. |
Any markers in the room list buffer will be set to position 1 when
erase-buffer
is called each time the buffer is rebuilt, which caused the window point to be forcibly moved to the start of the buffer in many situations.See #175