ema2159 / centaur-tabs

Emacs plugin aiming to become an aesthetic, modern looking tabs plugin
GNU General Public License v3.0
739 stars 50 forks source link

Vim/Elscreen tab behaviour #104

Closed alvinfrancis closed 4 years ago

alvinfrancis commented 4 years ago

Hello!

I've been looking at your tabs package for a while now as a potential replacement for the one that I use: elscreen. Coming from a vim background, I prefer tabs to be work more like workspaces which is what elscreen accomplishes for me. And so I was wondering if it was possible to configure this package to achieve the same effect. Been trying to fiddle around with it and having no success so far.

To be clear, in case you're not familiar with how it works in Vim, I'd want tabs to merely be sort of bookmarks for screens/sessions. In emacs parlance, I guess the best way to describe it would be I want the behaviour of frames under tabs. So that would mean tabs wouldn't be tied to buffers or even specific groups of buffers, but would be completely manual; just like how you would control the creation of emacs frames. And switching between tabs would be like switching between frames in emacs where each frame keeps the state of the windows it has open.

So just wanted to make sure first if such behaviour is even possible currently. If not, then no worries. That sort of behaviour might just run counter to how modern tabs work

ema2159 commented 4 years ago

Hi! centaur-tabs currently doesn't work that way, although it's a functionality that I'm thinking on implementing soon. It will work only in Emacs 27 though.

alvinfrancis commented 4 years ago

Ah that's good to know. I'm assuming it works with the new tabs functionality bundled in 27. Will be looking forward to it!

rickalex21 commented 2 years ago

@ema2159 Has this been feature been implemented? I'm limited to one workspace the way things are. In theory I could assign projects and buffers but I would have to do that every time for every file. In vim workspaces are automatic.

In Centaur its 1 Window (frame) > Tabs that are Buffers. In VIM it's 1 Frame -> Several Windows -> Buffers are in Tabs.

If this feature was implemented in Centaur, it would be a game changer. Thanks.

alvinfrancis commented 2 years ago

@rickalex21 I'm currently just directly using the built-in tab-bar-mode introduced in Emacs 27 and it has been working well so far; in that it matches the tab behaviour in vim. They are not as customizable as something like centaur tabs, but should suffice in terms of functionality.

For context, here is some relevant configuration I use:

  (defun +tab-bar/tab-name ()
    (let* ((buffer-name (concat " "
                                (buffer-name (window-buffer (minibuffer-selected-window)))
                                " ")))
      (concat
       (when (display-graphic-p)
         (+tabs--make-xpm ;; Can add images via XPM bitmaps
          nil
          +tabs-height
          +tabs-width))
       buffer-name)))

  (setq tab-bar-close-button-show nil
        tab-bar-format '(tab-bar-format-history
                         tab-bar-format-tabs
                         tab-bar-separator)
        tab-bar-show 1
        tab-bar-tab-name-function #'+tab-bar/tab-name
        tab-bar-separator ""
        tab-bar-new-tab-to 'rightmost)

  ;; Using aliases in case I switch tabs implementation
  (defalias #'+tabs/display #'toggle-tab-bar-mode-from-frame) ;; toggle tabs
  (defalias #'+tabs/new #'tab-bar-new-tab) ;; create new tab
  (defalias #'+tabs/close #'tab-bar-close-tab) ;; close tab
  (defalias #'+tabs/switch-left #'tab-bar-switch-to-prev-tab) ;; switch between tabs
  (defalias #'+tabs/switch-right #'tab-bar-switch-to-next-tab)

Hope this helps!

rickalex21 commented 2 years ago

@alvinfrancis Thanks, I get an error progn: Symbol’s function definition is void: +tabs--make-xpm on your script. Not a big deal, I'm using regular tab-bar with custom faces for now until I feel like ricing. Tab-bar works fine right out of the box with a couple of tweaks.