all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH] tab-line-alternate-colors
@ 2020-12-13  6:04 Adam Porter
  2020-12-13  6:17 ` Adam Porter
  2020-12-13  8:45 ` Juri Linkov
  0 siblings, 2 replies; 25+ messages in thread
From: Adam Porter @ 2020-12-13  6:04 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 278 bytes --]

Hi,

This patch adds a new option and face which makes inactive tab-line tabs display in alternating colors, which makes them easier to distinguish between.  Assuming that the idea is acceptable, please let me know if any further changes to the patch are required.

Thanks,
Adam

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 3505 bytes --]

From d1bebe1441f728b6da6bd44bc2a78a943594dafe Mon Sep 17 00:00:00 2001
From: Adam Porter <adam@alphapapa.net>
Date: Sun, 13 Dec 2020 05:54:28 +0000
Subject: [PATCH] New option `tab-line-alternate-colors` and associated face

* lisp/tab-line.el:
(tab-line-alternate-colors): New option.
(tab-line-tab-inactive-alternate): New face.
(tab-line-format-template): Use them.
---
 lisp/tab-line.el | 34 ++++++++++++++++++++++++++++------
 1 file changed, 28 insertions(+), 6 deletions(-)

diff --git a/lisp/tab-line.el b/lisp/tab-line.el
index 46bf89f14e..b8fcb737b9 100644
--- a/lisp/tab-line.el
+++ b/lisp/tab-line.el
@@ -35,6 +35,14 @@ tab-line
   :group 'convenience
   :version "27.1")
 
+(defcustom tab-line-alternate-colors t
+  "Alternate background colors of inactive tabs.
+When non-nil, alternating tabs use the face
+`tab-line-tab-inactive-alternate'."
+  :type 'boolean
+  :group 'tab-line
+  :version "28.1")
+
 (defgroup tab-line-faces '((tab-line custom-face)) ; tab-line is defined in faces.el
   "Faces used in the tab line."
   :group 'tab-line
@@ -63,6 +71,14 @@ tab-line-tab-inactive
   :version "27.1"
   :group 'tab-line-faces)
 
+(defface tab-line-tab-inactive-alternate
+  (let ((mode-line-bg (face-background 'mode-line nil t)))
+    `((t (:inherit tab-line-tab-inactive :background ,mode-line-bg))))
+  "Alternate face for inactive tab-line tabs.
+Used on alternating tabs when `tab-line-alternate-colors' is non-nil."
+  :version "28.1"
+  :group 'tab-line-faces)
+
 (defface tab-line-tab-current
   '((default
       :inherit tab-line-tab)
@@ -403,6 +419,7 @@ tab-line-format-template
   (let* ((selected-buffer (window-buffer))
          (separator (or tab-line-separator (if window-system " " "|")))
          (hscroll (window-parameter nil 'tab-line-hscroll))
+         (tab-number 0)
          (strings
           (mapcar
            (lambda (tab)
@@ -412,7 +429,16 @@ tab-line-format-template
                                   (cdr (assq 'selected tab))))
                     (name (if buffer-p
                               (funcall tab-line-tab-name-function tab tabs)
-                            (cdr (assq 'name tab)))))
+                            (cdr (assq 'name tab))))
+                    (face (cond (selected-p
+                                 (if (eq (selected-window) (old-selected-window))
+                                     'tab-line-tab-current
+                                   'tab-line-tab))
+                                ((and tab-line-alternate-colors
+                                      (cl-evenp (cl-incf tab-number)))
+                                 'tab-line-tab-inactive-alternate)
+                                (t
+                                 'tab-line-tab-inactive))))
                (concat
                 separator
                 (apply 'propertize
@@ -425,11 +451,7 @@ tab-line-format-template
                        `(
                          tab ,tab
                          ,@(if selected-p '(selected t))
-                         face ,(if selected-p
-                                   (if (eq (selected-window) (old-selected-window))
-                                       'tab-line-tab-current
-                                     'tab-line-tab)
-                                 'tab-line-tab-inactive)
+                         face ,face
                          mouse-face tab-line-highlight)))))
            tabs))
          (hscroll-data (tab-line-auto-hscroll strings hscroll)))
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2020-12-24 11:26 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-13  6:04 [PATCH] tab-line-alternate-colors Adam Porter
2020-12-13  6:17 ` Adam Porter
2020-12-13  8:45 ` Juri Linkov
2020-12-13 10:06   ` Adam Porter
2020-12-13 11:13     ` Adam Porter
2020-12-13 15:21     ` Eli Zaretskii
2020-12-14  2:17       ` Adam Porter
2020-12-14 15:34         ` Eli Zaretskii
2020-12-16  2:58           ` Adam Porter
2020-12-16 15:41             ` Eli Zaretskii
2020-12-13 21:25     ` Juri Linkov
2020-12-14  4:33       ` Adam Porter
2020-12-14  9:10         ` Juri Linkov
2020-12-14 10:05           ` Adam Porter
2020-12-14 19:37             ` Juri Linkov
2020-12-16  3:24               ` Adam Porter
2020-12-16  3:55                 ` Adam Porter
2020-12-16  9:03                 ` Juri Linkov
2020-12-16 10:26                   ` Adam Porter
2020-12-16 20:46                     ` Juri Linkov
2020-12-18  3:55                       ` Adam Porter
2020-12-23 21:07                         ` Juri Linkov
2020-12-24 11:26                           ` Adam Porter
2020-12-14  9:14         ` Adam Porter
2020-12-14 19:33           ` Juri Linkov

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.