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: [PATCH] tab-line: New tab-line-tab-face-modified face Date: Thu, 23 Sep 2021 23:57:09 -0500 Message-ID: <87bl4id10a.fsf@alphapapa.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="7567"; 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 Sep 24 06:58:31 2021 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 1mTdI7-0001nC-DQ for ged-emacs-devel@m.gmane-mx.org; Fri, 24 Sep 2021 06:58:31 +0200 Original-Received: from localhost ([::1]:53522 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTdI6-0004iA-GD for ged-emacs-devel@m.gmane-mx.org; Fri, 24 Sep 2021 00:58:30 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44726) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mTdH1-0003SV-3j for emacs-devel@gnu.org; Fri, 24 Sep 2021 00:57:23 -0400 Original-Received: from ciao.gmane.io ([116.202.254.214]:56288) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mTdGz-0007jb-DW for emacs-devel@gnu.org; Fri, 24 Sep 2021 00:57:22 -0400 Original-Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1mTdGv-0000EO-ST for emacs-devel@gnu.org; Fri, 24 Sep 2021 06:57:17 +0200 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: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.248, 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:275378 Archived-At: --=-=-= Content-Type: text/plain Hi Juri, et al, Spending some more time using Emacs 28.0.50 with tab-bar and tab-line, I found myself missing the ability to look at a tab-line tab and know whether its buffer is modified (e.g. after using `xref-query-replace-in-results' on some project buffers). This patch adds a face for modified, file-backed buffers. I chose to inherit from the font-lock-doc-face, as it seems readable and intuitive with the default theme. It seems to make the tab-line much more useful, and more in line with what users will probably expect from having used other editors' GUIs. -- Thanks, Adam --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-lisp-tab-line.el-Add-modified-buffer-face.patch Content-Description: Patch adding tab-line-tab-face-modified >From c5cd23ddbf2c8c5b96f4d07cb04a24e9f78c96b2 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Fri, 24 Sep 2021 04:47:56 +0000 Subject: [PATCH] * lisp/tab-line.el: Add modified-buffer face (tab-line-tab-modified): New face. (tab-line-tab-face-modified): New function. (tab-line-tab-face-functions): Use new function. * etc/NEWS: Update. --- etc/NEWS | 14 ++++++++------ lisp/tab-line.el | 21 ++++++++++++++++++++- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index b0e2d2c060..06e2e4f3eb 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -529,12 +529,14 @@ 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. buffers that don't visit a file. The face -'tab-line-tab-inactive-alternate' is used to display inactive tabs -with an alternating background color, making them easier to -distinguish, 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. +'tab-line-tab-modified' is used to display modified, file-backed +buffers. The face 'tab-line-tab-inactive-alternate' is used to +display inactive tabs with an alternating background color, making +them easier to distinguish, 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. ** Mouse wheel diff --git a/lisp/tab-line.el b/lisp/tab-line.el index 1f7af9e9a9..4a751b384e 100644 --- a/lisp/tab-line.el +++ b/lisp/tab-line.el @@ -36,13 +36,15 @@ tab-line :group 'convenience :version "27.1") -(defcustom tab-line-tab-face-functions '(tab-line-tab-face-special) +(defcustom tab-line-tab-face-functions + '(tab-line-tab-face-modified 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-modified) (function-item tab-line-tab-face-inactive-alternating) (function-item tab-line-tab-face-group) (function :tag "Custom function"))) @@ -92,6 +94,14 @@ tab-line-tab-special :version "28.1" :group 'tab-line-faces) +(defface tab-line-tab-modified + '((t :inherit font-lock-doc-face)) + "Face for modified tabs. +Applied when option `tab-line-tab-face-functions' includes +function `tab-line-tab-face-modified'." + :version "28.1" + :group 'tab-line-faces) + (defface tab-line-tab-group '((t :inherit tab-line :box nil)) "Face for group tabs. @@ -537,6 +547,15 @@ tab-line-tab-face-special (setf face `(:inherit (tab-line-tab-special ,face)))) face) +(defun tab-line-tab-face-modified (tab _tabs face buffer-p _selected-p) + "Return FACE for TAB according to whether it's modified. +When TAB is a modified, file-backed buffer, make FACE inherit +from `tab-line-tab-modified'. For use in +`tab-line-tab-face-functions'." + (when (and buffer-p (buffer-file-name tab) (buffer-modified-p tab)) + (setf face `(:inherit (tab-line-tab-modified ,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'." -- 2.20.1 --=-=-=--