From 29c0b640ba7bd076345d654fc5c393062eab83af Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Tue, 23 Feb 2021 21:01:31 +0200 Subject: * lisp/tab-line.el (tab-line-tab-name-format-function): New defcustom. (tab-line-tab-name-format-default): New function as the default value. (tab-line-format-template): Funcall tab-line-tab-name-format-function. This is like recently added tab-bar-tab-name-format-function. --- lisp/tab-line.el | 74 +++++++++++++++++++++++++++++++++----------------------- 1 file changed, 44 insertions(+), 30 deletions(-) (limited to 'lisp/tab-line.el') diff --git a/lisp/tab-line.el b/lisp/tab-line.el index 1bdddc2c83e..903862a3e83 100644 --- a/lisp/tab-line.el +++ b/lisp/tab-line.el @@ -430,42 +430,56 @@ variable `tab-line-tabs-function'." next-buffers))) +(defcustom tab-line-tab-name-format-function #'tab-line-tab-name-format-default + "Function to format a tab name. +Function gets two arguments: the tab and a list of all tabs, and +should return the formatted tab name to display in the tab line." + :type 'function + :initialize 'custom-initialize-default + :set (lambda (sym val) + (set-default sym val) + (force-mode-line-update)) + :group 'tab-line + :version "28.1") + +(defun tab-line-tab-name-format-default (tab tabs) + (let* ((buffer-p (bufferp tab)) + (selected-p (if buffer-p + (eq tab (window-buffer)) + (cdr (assq 'selected tab)))) + (name (if buffer-p + (funcall tab-line-tab-name-function tab tabs) + (cdr (assq 'name tab)))) + (face (if selected-p + (if (eq (selected-window) (old-selected-window)) + 'tab-line-tab-current + 'tab-line-tab) + 'tab-line-tab-inactive))) + (dolist (fn tab-line-tab-face-functions) + (setf face (funcall fn tab tabs face buffer-p selected-p))) + (apply 'propertize + (concat (propertize name 'keymap tab-line-tab-map) + (or (and (or buffer-p (assq 'buffer tab) (assq 'close tab)) + tab-line-close-button-show + (not (eq tab-line-close-button-show + (if selected-p 'non-selected 'selected))) + tab-line-close-button) + "")) + `( + tab ,tab + ,@(if selected-p '(selected t)) + face ,face + mouse-face tab-line-highlight)))) + (defun tab-line-format-template (tabs) "Template for displaying tab line for selected window." - (let* ((selected-buffer (window-buffer)) - (separator (or tab-line-separator (if window-system " " "|"))) + (let* ((separator (or tab-line-separator (if window-system " " "|"))) (hscroll (window-parameter nil 'tab-line-hscroll)) (strings (mapcar (lambda (tab) - (let* ((buffer-p (bufferp tab)) - (selected-p (if buffer-p - (eq tab selected-buffer) - (cdr (assq 'selected tab)))) - (name (if buffer-p - (funcall tab-line-tab-name-function tab tabs) - (cdr (assq 'name tab)))) - (face (if selected-p - (if (eq (selected-window) (old-selected-window)) - 'tab-line-tab-current - 'tab-line-tab) - 'tab-line-tab-inactive))) - (dolist (fn tab-line-tab-face-functions) - (setf face (funcall fn tab tabs face buffer-p selected-p))) - (concat - separator - (apply 'propertize - (concat (propertize name 'keymap tab-line-tab-map) - (or (and (or buffer-p (assq 'buffer tab) (assq 'close tab)) - tab-line-close-button-show - (not (eq tab-line-close-button-show - (if selected-p 'non-selected 'selected))) - tab-line-close-button) "")) - `( - tab ,tab - ,@(if selected-p '(selected t)) - face ,face - mouse-face tab-line-highlight))))) + (concat separator + (funcall tab-line-tab-name-format-function tab tabs))) tabs)) (hscroll-data (tab-line-auto-hscroll strings hscroll))) (setq hscroll (nth 1 hscroll-data)) -- cgit v1.2.3 From 0bfa9e78602a9c37c9ebd14bef43d15f6443d17c Mon Sep 17 00:00:00 2001 From: Gabriel do Nascimento Ribeiro Date: Fri, 12 Mar 2021 23:12:10 -0300 Subject: * lisp/tab-line.el: Add face for group-tab (bug#47118) (tab-line-tab-face-functions): Add choice for 'tab-line-tab-face-group'. (tab-line-tab-group): New face. (tab-line-tabs-buffer-groups): Set alist key 'group-tab' for group tabs. (tab-line-tab-face-group): New function to set face for group tabs. --- lisp/tab-line.el | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'lisp/tab-line.el') diff --git a/lisp/tab-line.el b/lisp/tab-line.el index 903862a3e83..c4b504aaad6 100644 --- a/lisp/tab-line.el +++ b/lisp/tab-line.el @@ -44,6 +44,7 @@ whether the tab is a buffer, and whether the tab is selected." :type '(repeat (choice (function-item tab-line-tab-face-special) (function-item tab-line-tab-face-inactive-alternating) + (function-item tab-line-tab-face-group) (function :tag "Custom function"))) :group 'tab-line :version "28.1") @@ -95,6 +96,16 @@ function `tab-line-tab-face-special'." :version "28.1" :group 'tab-line-faces) +(defface tab-line-tab-group + '((default + :inherit tab-line + :box nil)) + "Face for group tabs. +Applied when option `tab-line-tab-face-functions' includes +function `tab-line-tab-face-group'." + :version "28.1" + :group 'tab-line-faces) + (defface tab-line-tab-current '((default :inherit tab-line-tab) @@ -385,6 +396,7 @@ If the major mode's name string matches REGEXP, use GROUPNAME instead.") (set-window-parameter nil 'tab-line-group nil)))) (group-tab `(tab (name . ,group) + (group-tab . t) (select . ,(lambda () (set-window-parameter nil 'tab-line-groups t) (set-window-parameter nil 'tab-line-group group) @@ -520,6 +532,13 @@ When TAB is a non-file-backed buffer, make FACE inherit from (setf face `(:inherit (tab-line-tab-special ,face)))) face) +(defun tab-line-tab-face-group (tab _tabs face _buffer-p _selected-p) + "Return FACE for TAB according to whether it's a group tab. +For use in `tab-line-tab-face-functions'." + (when (alist-get 'group-tab tab) + (setf face `(:inherit (tab-line-tab-group ,face)))) + face) + (defvar tab-line-auto-hscroll) (defun tab-line-format () -- cgit v1.2.3 From 0a60e5d33c82803d68970c71a2e9ac9fcde5c2c6 Mon Sep 17 00:00:00 2001 From: Gabriel do Nascimento Ribeiro Date: Sat, 13 Mar 2021 19:04:55 -0300 Subject: * lisp/tab-line.el: Update docstring of 'tab-line-tabs-function' (bug#47117) (tab-line-tabs-function): Mention 'tab-line-tabs-buffer-groups' in the docstring. (tab-line-tabs-buffer-groups): Add docstring. --- lisp/tab-line.el | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'lisp/tab-line.el') diff --git a/lisp/tab-line.el b/lisp/tab-line.el index c4b504aaad6..f2c49019b14 100644 --- a/lisp/tab-line.el +++ b/lisp/tab-line.el @@ -305,7 +305,10 @@ be displayed, or just a list of strings to display in the tab line. By default, use function `tab-line-tabs-window-buffers' that returns a list of buffers associated with the selected window. When `tab-line-tabs-mode-buffers', return a list of buffers -with the same major mode as the current buffer." +with the same major mode as the current buffer. +When `tab-line-tabs-buffer-groups', return a list of buffers +grouped either by `tab-line-tabs-buffer-group-function', when set, +or by `tab-line-tabs-buffer-groups'." :type '(choice (const :tag "Window buffers" tab-line-tabs-window-buffers) (const :tag "Same mode buffers" @@ -367,6 +370,11 @@ If the major mode's name string matches REGEXP, use GROUPNAME instead.") mode)))) (defun tab-line-tabs-buffer-groups () + "Return a list of tabs that should be displayed in the tab line. +By default return a list of buffers grouped by major mode, +according to `tab-line-tabs-buffer-groups'. +If non-nil, `tab-line-tabs-buffer-group-function' is used to +generate the group name." (if (window-parameter nil 'tab-line-groups) (let* ((buffers (funcall tab-line-tabs-buffer-list-function)) (groups -- cgit v1.2.3 From 3cd3f230c924e5a095f37ea9c6ea6f9f6c5cf473 Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Wed, 17 Mar 2021 19:42:48 +0200 Subject: * lisp/tab-line.el: Face cleanup. --- lisp/tab-line.el | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) (limited to 'lisp/tab-line.el') diff --git a/lisp/tab-line.el b/lisp/tab-line.el index f2c49019b14..0d97da8ca71 100644 --- a/lisp/tab-line.el +++ b/lisp/tab-line.el @@ -56,29 +56,25 @@ whether the tab is a buffer, and whether the tab is selected." :version "27.1") (defface tab-line-tab - '((default - :inherit tab-line) + '((default :inherit tab-line) (((class color) (min-colors 88)) :box (:line-width 1 :style released-button)) - (t - :inverse-video nil)) + (t :inverse-video nil)) "Tab line face for selected tab." :version "27.1" :group 'tab-line-faces) (defface tab-line-tab-inactive - '((default - :inherit tab-line-tab) + '((default :inherit tab-line-tab) (((class color) (min-colors 88)) :background "grey75") - (t - :inverse-video t)) + (t :inverse-video t)) "Tab line face for non-selected tab." :version "27.1" :group 'tab-line-faces) (defface tab-line-tab-inactive-alternate - `((t (:inherit tab-line-tab-inactive :background "grey65"))) + '((t :inherit tab-line-tab-inactive :background "grey65")) "Alternate face for inactive tab-line tabs. Applied to alternating tabs when option `tab-line-tab-face-functions' includes function @@ -87,9 +83,9 @@ Applied to alternating tabs when option :group 'tab-line-faces) (defface tab-line-tab-special - '((default (:weight bold)) + '((default :weight bold) (((supports :slant italic)) - (:slant italic :weight normal))) + :slant italic :weight normal)) "Face for special (i.e. non-file-backed) tabs. Applied when option `tab-line-tab-face-functions' includes function `tab-line-tab-face-special'." @@ -97,9 +93,7 @@ function `tab-line-tab-face-special'." :group 'tab-line-faces) (defface tab-line-tab-group - '((default - :inherit tab-line - :box nil)) + '((t :inherit tab-line :box nil)) "Face for group tabs. Applied when option `tab-line-tab-face-functions' includes function `tab-line-tab-face-group'." @@ -107,8 +101,7 @@ function `tab-line-tab-face-group'." :group 'tab-line-faces) (defface tab-line-tab-current - '((default - :inherit tab-line-tab) + '((default :inherit tab-line-tab) (((class color) (min-colors 88)) :background "grey85")) "Tab line face for tab with current buffer in selected window." @@ -116,7 +109,7 @@ function `tab-line-tab-face-group'." :group 'tab-line-faces) (defface tab-line-highlight - '((default :inherit tab-line-tab)) + '((t :inherit tab-line-tab)) "Tab line face for highlighting." :version "27.1" :group 'tab-line-faces) @@ -189,7 +182,7 @@ If the value is a function, call it with no arguments." (defvar tab-line-new-button (propertize " + " - 'display `(image :type xpm + 'display '(image :type xpm :file "tabs/new.xpm" :margin (2 . 0) :ascent center) @@ -217,7 +210,7 @@ If nil, don't show it at all." (defvar tab-line-close-button (propertize " x" - 'display `(image :type xpm + 'display '(image :type xpm :file "tabs/close.xpm" :margin (2 . 0) :ascent center) @@ -228,7 +221,7 @@ If nil, don't show it at all." (defvar tab-line-left-button (propertize " <" - 'display `(image :type xpm + 'display '(image :type xpm :file "tabs/left-arrow.xpm" :margin (2 . 0) :ascent center) @@ -239,7 +232,7 @@ If nil, don't show it at all." (defvar tab-line-right-button (propertize "> " - 'display `(image :type xpm + 'display '(image :type xpm :file "tabs/right-arrow.xpm" :margin (2 . 0) :ascent center) -- cgit v1.2.3 From 274e71f5cc33834a08e7bd24418553198cb01f34 Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Thu, 8 Jul 2021 20:51:15 +0300 Subject: Don't turn mouse-1 into mouse-2 when clicking on the tab-line (bug#49247) * lisp/tab-line.el (tab-line-tab-name-format-default): For 'tab-line-tab-map' add the property 'follow-link' with the value 'ignore'. --- lisp/mouse.el | 4 ++-- lisp/tab-line.el | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'lisp/tab-line.el') diff --git a/lisp/mouse.el b/lisp/mouse.el index ab260d4ed49..89e5d7c48a3 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -1208,7 +1208,7 @@ overlay property, the value of that property determines what to do. for the `follow-link' event, the binding of that event determines what to do. -The resulting value determine whether POS is inside a link: +The resulting value determines whether POS is inside a link: - If the value is `mouse-face', POS is inside a link if there is a non-nil `mouse-face' property at POS. Return t in this case. @@ -2881,8 +2881,8 @@ is copied instead of being cut." (set-marker (nth 2 state) nil)) (with-current-buffer (window-buffer window) (setq cursor-type (nth 3 state))))))) - + ;;; Bindings for mouse commands. (global-set-key [down-mouse-1] 'mouse-drag-region) diff --git a/lisp/tab-line.el b/lisp/tab-line.el index 0d97da8ca71..d5fad353638 100644 --- a/lisp/tab-line.el +++ b/lisp/tab-line.el @@ -471,7 +471,10 @@ should return the formatted tab name to display in the tab line." (dolist (fn tab-line-tab-face-functions) (setf face (funcall fn tab tabs face buffer-p selected-p))) (apply 'propertize - (concat (propertize name 'keymap tab-line-tab-map) + (concat (propertize name + 'keymap tab-line-tab-map + ;; Don't turn mouse-1 into mouse-2 (bug#49247) + 'follow-link 'ignore) (or (and (or buffer-p (assq 'buffer tab) (assq 'close tab)) tab-line-close-button-show (not (eq tab-line-close-button-show -- cgit v1.2.3