mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-16 17:24:23 +00:00
tab-line: Allow to hide excluded buffers in the tab line. (Bug#79159)
* etc/NEWS: Announce changes. * lisp/tab-line.el (tab-line-tabs-window-buffers-filter-function): New user option. (tab-line-tabs-non-excluded): New function. (tab-line-tabs-window-buffers): Update.
This commit is contained in:
parent
c75c95ad58
commit
8f08cb386e
2 changed files with 34 additions and 3 deletions
5
etc/NEWS
5
etc/NEWS
|
|
@ -436,6 +436,11 @@ a buffer. The value must be a condition which is passed to
|
|||
With this user option, if non-nil (the default), the tab close button
|
||||
will change its appearance if the tab buffer has been modified.
|
||||
|
||||
---
|
||||
*** New user option 'tab-line-tabs-window-buffers-filter-function'.
|
||||
This user option controls which buffers should appear in the tab line.
|
||||
By default, this is set to not filter the buffers.
|
||||
|
||||
** Project
|
||||
|
||||
---
|
||||
|
|
|
|||
|
|
@ -569,6 +569,30 @@ generate the group name."
|
|||
sorted-buffers)))
|
||||
(cons group-tab tabs))))
|
||||
|
||||
(defcustom tab-line-tabs-window-buffers-filter-function
|
||||
#'identity
|
||||
"Filter which buffers should be displayed in the tab line."
|
||||
:type '(choice function
|
||||
(const :tag "No filter the buffers" identity)
|
||||
(const :tag "Show non-excluded buffers only" tab-line-tabs-non-excluded))
|
||||
:group 'tab-line
|
||||
:version "31.1")
|
||||
|
||||
(defvar tab-line-exclude-buffers)
|
||||
(defvar tab-line-exclude-modes)
|
||||
|
||||
(defun tab-line-tabs-non-excluded (buffers)
|
||||
"Filter BUFFERS and return non-excluded buffers list.
|
||||
Intended to be used in `tab-line-tabs-window-buffers-filter-function'."
|
||||
(seq-remove
|
||||
(lambda (b)
|
||||
(or (memq (buffer-local-value 'major-mode b)
|
||||
tab-line-exclude-modes)
|
||||
(buffer-match-p tab-line-exclude-buffers b)
|
||||
(get (buffer-local-value 'major-mode b) 'tab-line-exclude)
|
||||
(buffer-local-value 'tab-line-exclude b)))
|
||||
buffers))
|
||||
|
||||
(defun tab-line-tabs-window-buffers ()
|
||||
"Return a list of tabs that should be displayed in the tab line.
|
||||
By default returns a list of window buffers, i.e. buffers previously
|
||||
|
|
@ -585,9 +609,11 @@ variable `tab-line-tabs-function'."
|
|||
(prev-buffers (seq-filter #'buffer-live-p prev-buffers))
|
||||
;; Remove next-buffers from prev-buffers
|
||||
(prev-buffers (seq-difference prev-buffers next-buffers)))
|
||||
(append (reverse prev-buffers)
|
||||
(list buffer)
|
||||
next-buffers)))
|
||||
(funcall
|
||||
tab-line-tabs-window-buffers-filter-function
|
||||
(append (reverse prev-buffers)
|
||||
(list buffer)
|
||||
next-buffers))))
|
||||
|
||||
(defun tab-line-tabs-fixed-window-buffers ()
|
||||
"Like `tab-line-tabs-window-buffers' but keep stable sorting order.
|
||||
|
|
|
|||
Loading…
Reference in a new issue