thread314 / intuitive-tab-line-mode

GNU General Public License v3.0
20 stars 3 forks source link
  1. Clone into a folder of your choice (~/.emacs.d/git for example)
  2. With use-package, configure it like this (with suggested key bindings):

+BEGIN_SRC emacs-lisp

(use-package intuitive-tab-line :load-path "git/intuitive-tab-line-mode" :custom (tab-line-tabs-function 'intuitive-tab-line-buffers-list) (tab-line-switch-cycling t) :config (global-tab-line-mode 1) (recentf-mode 1) (setq tab-line-new-button-show nil ;; do not show add-new button tab-line-close-button-show nil ;; do not show close button tab-line-separator " " ;; delimitation between tabs ))

(global-set-key (kbd "C-<prior>") 'tab-line-switch-to-prev-tab)
(global-set-key (kbd "C-<iso-lefttab>") 'tab-line-switch-to-prev-tab)
(global-set-key (kbd "C-<next>") 'tab-line-switch-to-next-tab)
(global-set-key (kbd "C-<tab>") 'tab-line-switch-to-next-tab)
(global-set-key (kbd "C-S-<prior>") 'intuitive-tab-line-shift-tab-left)
(global-set-key (kbd "C-S-<next>") 'intuitive-tab-line-shift-tab-right)
(global-set-key (kbd "C-S-t") 'recentf-open-most-recent-file)

+END_SRC

** The Goal:

Make Emacs tabs behave intuitively (similar to how tabs behave in a browser).

** Problem:

I know many don't feel this way, but I like using tabs. And more than this, I like the simplicity of having one buffer per tab.

I tried doing things The Emacs Way (TM) of having buffers managed invisibly in the background, but I could never get a good mental model for this. I needed a visual representation of what buffers were open and their order.

What I wanted was:

Put simply, I want Emacs tabs to work like a browser would.

** The Final Solution:

So using ~tab-line-mode~ I have created my own custom ~tab-line-tabs-function~: a simple list to manage the tab/buffers I wanted displayed. I then created a set of functions to manipulate that list to get the functionality I was after.

The various functions should more or less be self-explanatory. Please note I use ~tab-line-switch-to-next-tab~ and ~tab-line-switch-to-prev-tab~ to cycle between tabs.

Tested with Emacs 28.1.

** Notes:

** Conclusion:

As I say, this has been a goal of mine ever since I started using Emacs. It was a lot of confusing work to get it to work, but work it does and it is enormously gratifying. Very open to feedback and criticism, but do keep in mind I'm not a programmer and trying my best.