Subject: Re: bug#59381: Should xref--marker-ring be per-window?

From: Dmitry Gutov <[email-masked]>
Date: Thu, 24 Nov 2022 05:19:22 +0200

On 21/11/22 15:14, Eli Zaretskii wrote:
>> Date: Mon, 21 Nov 2022 01:17:02 +0200
>> Cc: [email-masked], [email-masked], [email-masked]
>> From: Dmitry Gutov <[email-masked]>
>>
>> On 20.11.2022 09:59, Eli Zaretskii wrote:
>>
>>>> But maybe it will be helpful for you to elaborate: what the workflow
>>>> would look like. Would it be a parallel set of commands, or simply a
>>>> command to... do what?
>>>
>>> I just did that, above: add a command that starts a new "stack".  All the
>>> rest is unchanged.
>>
>> What would happen with the current stack, though?
> 
> It's discarded, as no longer needed.

That sounds odd. The idea regarding windows is about keeping multiple 
stacks at the same time, not about discarding information.

>> Or does it apply to the current window? What about the windows split
>> from it? What about older windows we decide to pop-to-buffer to from one
>> of the new windows?
> 
> In my mental picture, the stack is not specific to a window, like it is
> today.
> 
>>>> In my workflow, a new stack is more or less created implicitly by
>>>> splitting a window, and discarded by deleting one.
>>>
>>> So you always ever have a given buffer displayed in a single window?
>>
>> Not necessarily, no. If it's a big file, I can have two parallel
>> "investigations" going on in two different window on it. Using two
>> different navigation stacks. That's a feature.
> 
> It's a feature if you indeed want a separate stack in each window.  What if
> you want the same stack in all of those windows?

Maybe you never do? Or if you really do, that would require some 
additional manual management (through new commands, I suppose).

>> Whether M-. pop a new window, or you use project-find-regexp, we usually
>> make sure that after you navigate to a location, it's displayed in the
>> same window the search was made in. Unless the user called something
>> like xref-find-definitions-other-window, naturally.
>>
>> So it's generally possible to stay within the same window most of the time.
> 
> Not if I split that one window because I want to look at something else as
> well.

In my book that's starting a new line of thought, where it's okay to 
create a new stack. The old one is still around.

>> And you make good points: Emacs often makes you go from a window to a
>> window, reusing older windows as well. So I'm not sure how to solve that
>> better: searching the window hierarchy won't help.
>>
>> So it could be some propagation mechanism working when windows are split
>> or buffers get displayed, which would nevertheless leave a window when
>> the user pressed 'q', for instance. Reverting the window to its previous
>> stack, let's say. And as for separate command, using it explicitly by
>> itself is easy to forget, but it perhaps could be added to some other
>> commands by the user (via before-advice or etc), to mark the beginning
>> of each stack.
>>
>> This is a very rough idea. There's nobody to work on it in the near
>> future, I'm afraid, so adding an optional change in behavior to use
>> window-local storage is probably the best way forward. To get feedback,
>> as Ackerley said.
> 
> When this becomes practical, we could try it and see if enough people like
> it.

I don't know if it's practical or not, but it requires some additional 
design for sure. Maybe someday.