From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Adam Porter Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] tab-line-alternate-colors Date: Thu, 17 Dec 2020 21:55:26 -0600 Message-ID: <87y2hvlqdt.fsf@alphapapa.net> References: <87360autpy.fsf@alphapapa.net> <87mtyiqfzv.fsf@mail.linkov.net> <87tusqt3yr.fsf@alphapapa.net> <87wnxl760u.fsf@mail.linkov.net> <87h7opt3a4.fsf@alphapapa.net> <87blewpwf5.fsf@mail.linkov.net> <878sa0u2hn.fsf@alphapapa.net> <87360847c8.fsf@mail.linkov.net> <878s9yxwjc.fsf@alphapapa.net> <87a6ueruko.fsf@mail.linkov.net> <87zh2evyh1.fsf@alphapapa.net> <878s9xii5z.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2658"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Dec 18 04:56:25 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kq6sS-0000bG-VC for ged-emacs-devel@m.gmane-mx.org; Fri, 18 Dec 2020 04:56:25 +0100 Original-Received: from localhost ([::1]:47488 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kq6sS-0004TR-1g for ged-emacs-devel@m.gmane-mx.org; Thu, 17 Dec 2020 22:56:24 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33736) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kq6rg-0003yw-Ui for emacs-devel@gnu.org; Thu, 17 Dec 2020 22:55:36 -0500 Original-Received: from ciao.gmane.io ([116.202.254.214]:54810) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kq6re-00028Y-Gx for emacs-devel@gnu.org; Thu, 17 Dec 2020 22:55:36 -0500 Original-Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1kq6rc-000AG2-R3 for emacs-devel@gnu.org; Fri, 18 Dec 2020 04:55:32 +0100 X-Injected-Via-Gmane: http://gmane.org/ Received-SPF: pass client-ip=116.202.254.214; envelope-from=ged-emacs-devel@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.25, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:261149 Archived-At: --=-=-= Content-Type: text/plain Juri Linkov writes: >>> Thanks, everything looks right. The only thing I'm unsure about is >>> the default value. I don't know how important is to highlight the >>> distinction between file and non-file buffers. But it's a matter of >>> taste, so I can't argue against or for a specific default value. >> >> I don't know how important it is, either. :) But I think it's very >> helpful for distinguishing buffers, especially in the smaller text of >> the tab-line. It seems to me that it does no harm, and it seems more >> useful than not, so it seems that it might as well be the default. > > The problem is that it's not self-evident to the users why some tabs > are displayed in italic, and other tabs are not. You're right, but I would say that many things in Emacs aren't self-evident but are useful. :) Of course, I'll defer to your or the other maintainers' judgment if this seems like a bad idea. > But if no one opposed to this change, then etc/NEWS should explain > the difference of tab styles for the new default value. This new patch includes such a news entry. Thanks for your guidance with this work. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-lisp-tab-line.el-New-options-faces-and-functions.patch Content-Description: patch >From d92420dc655368dcac7eaa6742001bdd1b3f122c Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Sun, 13 Dec 2020 05:54:28 +0000 Subject: [PATCH] * lisp/tab-line.el: New options, faces, and functions * lisp/tab-line.el: (tab-line-tab-face-functions): New option. (tab-line-tab-inactive-alternate): New face. (tab-line-tab-special): New face. (tab-line-tab-face-inactive-alternating): New function. (tab-line-tab-face-special): New function. (tab-line-format-template): Use them. * etc/NEWS: Update. With thanks to Juri Linkov and Eli Zaretskii for their guidance. --- etc/NEWS | 12 +++++++++++ lisp/tab-line.el | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 71 insertions(+), 6 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 909473f..2233139 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -371,6 +371,18 @@ value of 'tab-bar-show'. If your mouse or trackpad supports it, you can now scroll tabs when the mouse pointer is in the tab line by scrolling left or right. +--- +*** New tab-line faces and options +The face 'tab-line-tab-special' is used for tabs whose buffers are +special, i.e. not file-backed. The face +'tab-line-tab-inactive-alternate' is used to display inactive tabs +with an alternating background color, making them easier to +distinguish between, especially if the face 'tab-line-tab' is +configured to not display with a box; this alternate face is only +applied when the option 'tab-line-tab-face-functions' is +so-configured. That option may also be used to customize tab-line +faces in other ways. + ** New bindings in occur-mode, 'next-error-no-select' bound to 'n' and 'previous-error-no-select' bound to 'p'. diff --git a/lisp/tab-line.el b/lisp/tab-line.el index 46bf89f..c944471 100644 --- a/lisp/tab-line.el +++ b/lisp/tab-line.el @@ -27,6 +27,7 @@ ;;; Code: +(require 'cl-lib) (require 'seq) ; tab-line.el is not pre-loaded so it's safe to use it here @@ -35,6 +36,18 @@ tab-line :group 'convenience :version "27.1") +(defcustom tab-line-tab-face-functions '(tab-line-tab-face-special) + "Functions called to modify tab faces. +Each function is called with five arguments: the tab, a list of +all tabs, the face returned by the previously called modifier, +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 :tag "Custom function"))) + :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 +76,25 @@ tab-line-tab-inactive :version "27.1" :group 'tab-line-faces) +(defface tab-line-tab-inactive-alternate + `((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 +`tab-line-tab-face-inactive-alternating'." + :version "28.1" + :group 'tab-line-faces) + +(defface tab-line-tab-special + '((default (:weight bold)) + (((supports :slant italic)) + (: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'." + :version "28.1" + :group 'tab-line-faces) + (defface tab-line-tab-current '((default :inherit tab-line-tab) @@ -412,7 +444,14 @@ 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 (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 @@ -425,11 +464,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))) @@ -453,6 +488,24 @@ tab-line-format-template tab-line-new-button) (list tab-line-new-button))))) +(defun tab-line-tab-face-inactive-alternating (tab tabs face _buffer-p selected-p) + "Return FACE for TAB in TABS with alternation. +When TAB is an inactive buffer and is even-numbered, make FACE +inherit from `tab-line-tab-inactive-alternate'. For use in +`tab-line-tab-face-functions'." + (when (and (not selected-p) (cl-evenp (cl-position tab tabs))) + (setf face `(:inherit (tab-line-tab-inactive-alternate ,face)))) + face) + +(defun tab-line-tab-face-special (tab _tabs face buffer-p _selected-p) + "Return FACE for TAB according to whether it's special. +When TAB is a non-file-backed buffer, make FACE inherit from +`tab-line-tab-special'. For use in +`tab-line-tab-face-functions'." + (when (and buffer-p (not (buffer-file-name tab))) + (setf face `(:inherit (tab-line-tab-special ,face)))) + face) + (defvar tab-line-auto-hscroll) (defun tab-line-format () -- 2.7.4 --=-=-=--