Comments (13)
So this ends up being about configuring consult, and not tabspaces. But here is the kind of thing I think you want?
(defvar consult--source-tab-buffer
`(:name "Tab & Buffer"
:narrow ?B
:hidden t
:category buffer
:face consult-buffer
:history buffer-name-history
:items
,(lambda () (consult--buffer-query :sort 'visibility
:as #'buffer-name))
:action ,#'tabspaces-switch-buffer-and-tab)
"Buffer candidate source for `consult-buffer'.")
(add-to-list 'consult-buffer-sources consult--source-tab-buffer)
So narrow using "B" and you get a list of all open buffers. Selecting a buffer with "Return" will take you to that buffer in its tab.
from tabspaces.
Since there is no guarantee that a buffer will be in only one tabspace this would be somewhat tricky to implement.
For my cases, most of the time the behavior would be ideal. For the cases where a buffer is in more than one tabspace, you could simply prompt the user with the list of tabspaces?
Of course, this would almost certainly need to be opt-in since I'm sure many others workflows have lots of duplication of buffers across tabspaces.
from tabspaces.
Yeah so something like the following works for me.
(defvar-keymap embark-tabspaces-actions
:doc "Keymap for actions for tabspaces."
:parent embark-general-map
"B" #'tab-bar-select-tab-by-name)
(add-to-list 'embark-keymap-alist '(buffer . embark-tabspaces-actions))
So I can open consult-buffer, this has my tabspace buffers at the top. I can then press "b" to show all buffers in all tabspaces. Narrow to the one I want. Run embark-act
on it. And then choose "B" to switch to the buffer and tab. This seems elegant enough for me, so I'm unlikely to build it into tabspaces itself.
from tabspaces.
Since there is no guarantee that a buffer will be in only one tabspace this would be somewhat tricky to implement. I think a better option would be to use something like embark to act on a buffer from the full (i.e. across all tabs) buffer list. Of course, I'm happy to accept a pull request if you end up implementing this.
from tabspaces.
Yeah, making it opt in seems like a good idea. I'm not sure I have time right now to implement something like this but it seems a fair request. If I can find time soon I will try and see what i can do. As I said above though I welcome PRs!
from tabspaces.
@Yevgnen and @ParetoOptimalDev I've added a function tabspaces-switch-buffer-and-tab
which I think provides the desired behavior (see f48b041). It allows you to see the full buffer list (not just the ones in the current tabspace) and switch to the buffer in its tab. If that buffer does not exist you have the option of either opening a new tabspace with the buffer or opening the buffer in the current tabspace. If you would test it out and let me know what you think that would be very helpful.
from tabspaces.
See f25bb67 for revisions and coverage of the case in which the buffer is open in more than one tabspace. I'm sure the code can be improved so suggestions welcome.
from tabspaces.
@mclearc Wow thanks! I'll try this out today 😀
from tabspaces.
Hi @mclearc, I just got around to trying this. It enables half of what I need to make my "project buffers by default, but when 'narrowing' with b to show all buffers switch tabspaces` vision.
I think that with this new function I should be able to get the functionality by just adding this to my config?
(plist-put consult--source-buffer :action #'tabspaces-switch-buffer-and-tab)
Edit: That apparently asks me to Select tab
and provides no completions.
OH! It's because I'm using previews in consult which implicitly opens the buffer in the tabspace.
That makes me realize that switching tab on preview might would improve this idea even more!
But that would require making consult-register-format
tabspace aware if I understand correctly.
from tabspaces.
Even with preview disabled it seems it doesn't work and falls into the "create buffer in new tab" case.
from tabspaces.
If you use embark I think you could run an embark action on the buffer from the full buffer list?
from tabspaces.
@mclearc I understand your position, but I just had a realization about the nature of what I'm asking for.
Right now when you narrow with b
in consult-buffer to show all buffers the default action is to "add selected buffer to your current workspace".
I want the default behavior when narrowed to b
in consult-buffer to be "switch to tab buffer is opened in" because it's most common for me to only show all buffers when I need to switch to a different tabspace.
Then I'd add an embark action for the less common case (for me) for "add selected buffer to your current workspace".
I'm guessing your common case when showing all buffers is to add a buffer to the tabspace and this won't affect your current position?
Would it be amenable to provide customization for something like "consult-all-buffers-default-action-function"? I'm not quite sure if that's possible or would add to much complexity. I also don't know if there are others whose common case matches mine or I'm the odd one out 🙃
Anyway, thanks for the snippet, discussion, etc! 😄
from tabspaces.
So this ends up being about configuring consult, and not tabspaces. But here is the kind of thing I think you want?
(defvar consult--source-tab-buffer `(:name "Tab & Buffer" :narrow ?B :hidden t :category buffer :face consult-buffer :history buffer-name-history :items ,(lambda () (consult--buffer-query :sort 'visibility :as #'buffer-name)) :action ,#'tabspaces-switch-buffer-and-tab) "Buffer candidate source for `consult-buffer'.") (add-to-list 'consult-buffer-sources consult--source-tab-buffer)So narrow using "B" and you get a list of all open buffers. Selecting a buffer with "Return" will take you to that buffer in its tab.
Wow...That is perfect! Thanks for the support.
from tabspaces.
Related Issues (20)
- Rename created tabspace HOT 2
- [BUG] two projects with same name are considered as one workspace HOT 1
- [SUGGESTION] a nicer tabspaces-ivy-switch-buffer HOT 1
- [SUGGESTION] Don't overwrite `project-switch-commands` HOT 2
- Customise `magit-init` call when opening a project HOT 1
- Unusable `tabspaces-open-or-create-project-and-workspace` HOT 3
- [SUGGESTION] Enable tabspace duplication only when `tabspaces-open-or-create-project-and-workspace` is called with C-u prefix HOT 2
- [BUG] two projects with same name are considered as one workspace HOT 18
- Switch between tabspaces HOT 2
- Question about tabspaces-exclude-buffers HOT 1
- Missing support for tab-group / integration with desktop.el HOT 4
- tabspaces-switch-or-create doesn't create empty workspace HOT 7
- Displays *Messages* buffer HOT 8
- Mixing tabspaces-switch-to-buffer with tab-bar-select-tab leaks buffer to another tab HOT 3
- Is it possible to create workspaces based on modes? HOT 4
- "Bury-buffer" alse removes the buffer from current tab HOT 2
- Switch buffer and tab from ibuffer
- Integration with projectile HOT 1
- startup error when tabspaces session file does not yet exist
- allow opting out of automatic keymap prefix binding HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tabspaces.