help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Help customising the behaviour of the new Tab Line mode


From: Juri Linkov
Subject: Re: Help customising the behaviour of the new Tab Line mode
Date: Mon, 17 Aug 2020 03:33:36 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu)

> For example, I tend to have source.h to the left and source.cpp to the
> right, so that I can quickly switch between them. I tend to keep all such
> .h & .cpp files in pairs on the tab bar.
> [...]
> Issue 1) The first thing I noticed is that 'compile' creates
> a window/pane/whatever for the compilation output, and the tab line at the
> top does not show the compilation buffert. In fact, if I call
> split-window-below, the tab line below only has the current buffer on
> it. However, I would like all Tab Lines to show all buffers (or at least
> all buffers visited in the whole frame). And I want all those buffers to
> have the same tab order (because my positional memory is useful, but
> limited). That would match the behaviour of the old tabbar.el package. How
> do I achieve that? Please remember that my Lisp is rather limited. I can
> tinker, but it won't be pretty. 8-)

Please try this code:

(defun tab-line-tabs-mode-sorted-buffers ()
  "Return a list of buffers sorted by file name and file extension."
  (seq-sort-by #'buffer-name
               (lambda (a b)
                 (cond
                  ((equal (file-name-sans-extension a) 
(file-name-sans-extension b))
                   (string> (file-name-extension a) (file-name-extension b)))
                  (t
                   (string< a b))))
               (seq-filter (lambda (b) (and (buffer-live-p b)
                                            (/= (aref (buffer-name b) 0) ?\s)))
                           (buffer-list))))

(setq tab-line-tabs-function 'tab-line-tabs-mode-sorted-buffers)

Does it sort tabs in the order that you prefer?

It keeps .h & .cpp files in pairs where source.h is to the left
and source.cpp to the right.



reply via email to

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