Git Product home page Git Product logo

Comments (13)

mclearc avatar mclearc commented on July 20, 2024 2

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.

ParetoOptimalDev avatar ParetoOptimalDev commented on July 20, 2024 1

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.

mclearc avatar mclearc commented on July 20, 2024 1

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.

mclearc avatar mclearc commented on July 20, 2024

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.

mclearc avatar mclearc commented on July 20, 2024

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.

mclearc avatar mclearc commented on July 20, 2024

@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.

mclearc avatar mclearc commented on July 20, 2024

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.

ParetoOptimalDev avatar ParetoOptimalDev commented on July 20, 2024

@mclearc Wow thanks! I'll try this out today 😀

from tabspaces.

ParetoOptimalDev avatar ParetoOptimalDev commented on July 20, 2024

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.

ParetoOptimalDev avatar ParetoOptimalDev commented on July 20, 2024

Even with preview disabled it seems it doesn't work and falls into the "create buffer in new tab" case.

from tabspaces.

mclearc avatar mclearc commented on July 20, 2024

If you use embark I think you could run an embark action on the buffer from the full buffer list?

from tabspaces.

ParetoOptimalDev avatar ParetoOptimalDev commented on July 20, 2024

@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.

ParetoOptimalDev avatar ParetoOptimalDev commented on July 20, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.