Bad-ptr / persp-mode.el

named perspectives(set of buffers/window configs) for emacs
394 stars 44 forks source link

add support for handling cloned indirect buffers #129

Open dankessler opened 2 years ago

dankessler commented 2 years ago

Currently, if a user clones a buffer (with e.g., 'clone-indirect-buffer'), the new clone will not be added to the current perspective.

This can be a little surprising: suppose I'm working on buffer native.txt in my current perspective and I call clone-indirect-buffer. I'll now have native.txt<2> displayed, but it is not in the current perspective.

I think the most reasonable behavior is for persp-mode to automatically add freshly cloned indirect buffers to the current workspace if the base-buffer is already in the current perspective (e.g.., if you are temporarily displaying buffer foreign.txt and then clone it, the new clone foreig.txt<2> probably should respect your wishes and not add itself to the current workspace).

However, I appreciate that users will have different tastes, so I've added a new customization option so they can restore the old behavior (nil), use what I think is the most natural behavior (t, the new default), or can set it to ('always') so that cloning always adds the newly cloned indirect buffer to the current perspective regardless of whether the base-buffer is a member or not.

I'm open to changing the default to nil, which would retain the "old" behavior and avoid annoying anyone that was relying on it, but I suspect there aren't many people who clone buffers that do not want them added to the current workspace.

dankessler commented 2 years ago

After using the patched version for a bit, I realize that this does not improve the behavior of indirect buffers created using Org-Mode's convenience functions (e.g., org-tree-to-indirect-buffer), since these call make-indirect-buffer directly rather than using any of the clone* commands. Unfortunately, as far as I can tell make-indirect-buffer does not have any associated hooks that could be exploited to modify behavior, but I'll try to think of a way to make this play nice with Org.