[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Tabs

From: Juri Linkov
Subject: Re: Tabs
Date: Sun, 27 Oct 2019 01:40:41 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu)

> I've now just found out that what I want is to use a tab-line, like this:
> #+begin_src emacs-lisp
> (require 'tab-line)
> (setq-default tab-line-format nil)
> (setq-default tab-line-close-tab-action #'kill-buffer)
> (setq-default
>  tab-line-tabs-function
>  (defun my-tab-line-get-mode-tabs ()
>    (cl-sort
>     (let ((mode major-mode))
>       (delq nil
>             (mapcar
>              (lambda (b)
>                (and (with-current-buffer b
>                       (derived-mode-p mode))
>                     (not (string-match-p (rx bos " ")
>                                          (buffer-name b)))
>                     b))
>              (buffer-list))))
>             #'string< :key #'buffer-name)))
> (defun my-enable-tab-line ()
>   (setq-local tab-line-format '(:eval (tab-line-format))))
> (dolist (hook '(Info-mode-hook eww-mode-hook))
>   (add-hook hook #'my-enable-tab-line))
> #+end_src
> [...]
> I see that you did not have my use case in mind when I e.g. try
> `tab-line-switch-to-next-tab': it switches to buffers that are not
> displayed in the tab-line, and the tab-line just vanishes.
> Maybe there could be different tab-bar/tab-line modes for the different
> use cases, or something like that, haven't thought about it.

Thanks for posting the use case with real needs, so now it's clear
how to make tab-line customizable.

Now you can replace all code above with just 3 lines:

  (setq tab-line-tabs-function #'tab-line-tabs-mode-buffers)
  (dolist (hook '(Info-mode-hook eww-mode-hook))
    (add-hook hook #'tab-line-mode))

This is because now tab-line-tabs-function is customizable to the
function that populates the tab-line with buffers having the same mode.

Also there is separate global-tab-line-mode that affects all buffers
and buffer-local tab-line-mode.

tab-line-switch-to-next-tab works as well in your case now.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]