unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#46358: 28.0.50; [PATCH] Add vc-dir faces; also apply them to vc-git
@ 2021-02-07 11:42 Protesilaos Stavrou
  2021-02-07 15:15 ` Eli Zaretskii
  0 siblings, 1 reply; 18+ messages in thread
From: Protesilaos Stavrou @ 2021-02-07 11:42 UTC (permalink / raw)
  To: 46358

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

Dear maintainers,

The vc-dir.el library hardcodes all of its faces to generic font-lock
ones.  This makes it impossible for users/themes to exert any control
over the presentation of those buffers.

In the attached patch, I do the following:

1. Define new faces.  Each has semantic value in that it applies to
   constructs implied by its name.

2. Cover the vc-git backend's implementation of extra vc-dir headers.
   This necessarily means that not all backends are brought to the same
   state after applying this patch.

3. Address a "FIXME" comment in vc-git.el concerning the use of a
   bespoke face for the stash header's value when that is empty.

4. Use new color combinations which conform with the WCAG AAA standard
   for color contrast against pure white/black (this standard pertains
   to legibility and is the highest of its kind).

With regard to point 2, I only use Git and thus cannot test the other
backends with the requisite degree of confidence.  Do you think I should
try regardless?  Or should we just support the Git backend and hope that
someone else will work on [some of] the other backends?

On point 4, please consider this a proposal: it is a highly opinionated
change.  If you feel we should in no way alienate existing users, I am
prepared to remove all colors and just :inherit from the faces that
applied before.

I attach a couple of screenshots showcasing the expected results.

Please let me know what you think.  I remain at your disposal for any
possible amendments to this patch, assuming you are willing to merge it.

All the best,
Protesilaos

-- 
Protesilaos Stavrou
protesilaos.com

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Add-vc-dir-faces-also-apply-them-to-vc-git.patch --]
[-- Type: text/x-patch, Size: 11404 bytes --]

From 9ee98edc88d90479ea6e67406776bd9676e9af32 Mon Sep 17 00:00:00 2001
Message-Id: <9ee98edc88d90479ea6e67406776bd9676e9af32.1612697511.git.info@protesilaos.com>
From: Protesilaos Stavrou <info@protesilaos.com>
Date: Sun, 7 Feb 2021 13:12:43 +0200
Subject: [PATCH] Add vc-dir faces; also apply them to vc-git

* etc/NEWS: Document the new faces.

* lisp/vc/vc-dir.el (vc-dir-header, vc-dir-header-value)
(vc-dir-directory, vc-dir-file, vc-dir-mark-indicator)
(vc-dir-status-warning, vc-dir-status-edited, vc-dir-status-up-to-date)
(vc-dir-ignored): Add new faces.

(vc-dir-headers, vc-default-dir-extra-headers)
(vc-default-dir-printer): Apply new faces.

* lisp/vc/vc-git.el (vc-git-permissions-as-string, vc-git-dir-printer)
(vc-git-dir-extra-headers): Apply new faces.
---
 etc/NEWS          |  6 +++
 lisp/vc/vc-dir.el | 94 +++++++++++++++++++++++++++++++++++++++++------
 lisp/vc/vc-git.el | 36 +++++++++---------
 3 files changed, 107 insertions(+), 29 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index fb77688470..475b29b8f5 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -587,6 +587,12 @@ their 'default-directory' under VC.
 This is used when expanding commit messages from 'vc-print-root-log'
 and similar commands.
 
+---
+*** New faces for 'vc-dir' buffers and their Git VC backend.
+Those are: 'vc-dir-header', 'vc-dir-header-value', 'vc-dir-directory',
+'vc-dir-file', 'vc-dir-mark-indicator', 'vc-dir-status-warning',
+'vc-dir-status-edited', 'vc-dir-status-up-to-date', 'vc-dir-ignored'.
+
 ---
 *** The responsible VC backend is now the most specific one.
 'vc-responsible-backend' loops over the backends in
diff --git a/lisp/vc/vc-dir.el b/lisp/vc/vc-dir.el
index 9d0808c043..67792fb6e7 100644
--- a/lisp/vc/vc-dir.el
+++ b/lisp/vc/vc-dir.el
@@ -54,6 +54,78 @@ vc-dir-mode-hook
   :type 'hook
   :group 'vc)
 
+(defface vc-dir-header
+  '((((class color) (min-colors 88) (background light))
+     :foreground "#005a5f")
+    (((class color) (min-colors 88) (background dark))
+     :foreground "#6ae4b9")
+    (t :inherit font-lock-type-face))
+  "Face for headers in VC-dir buffers.")
+
+(defface vc-dir-header-value
+  '((((class color) (min-colors 88) (background light))
+     :foreground "#5317ac")
+    (((class color) (min-colors 88) (background dark))
+     :foreground "#b6a0ff")
+    (t :inherit font-lock-variable-name-face))
+  "Face for header values in VC-dir buffers.")
+
+(defface vc-dir-directory
+  '((((class color) (min-colors 88) (background light))
+     :foreground "#0031a9")
+    (((class color) (min-colors 88) (background dark))
+     :foreground "#2fafff")
+    (t :inherit font-lock-comment-delimiter-face))
+  "Face for directories in VC-dir buffers.")
+
+(defface vc-dir-file
+  '((((class color) (min-colors 88) (background light))
+     :foreground "#000000")
+    (((class color) (min-colors 88) (background dark))
+     :foreground "#ffffff")
+    (t :inherit font-lock-function-name-face))
+  "Face for files in VC-dir buffers.")
+
+(defface vc-dir-mark-indicator
+  '((((class color) (min-colors 88) (background light))
+     :foreground "#0000c0")
+    (((class color) (min-colors 88) (background dark))
+     :foreground "#00bcff")
+    (t :inherit font-lock-keyword-face))
+  "Face for mark indicators in VC-dir buffers.")
+
+(defface vc-dir-status-warning
+  '((((class color) (min-colors 88) (background light))
+     :foreground "#a60000")
+    (((class color) (min-colors 88) (background dark))
+     :foreground "#ff8059")
+    (t :inherit font-lock-warning-face))
+  "Face for warning status in VC-dir buffers.")
+
+(defface vc-dir-status-edited
+  '((((class color) (min-colors 88) (background light))
+     :foreground "#863927")
+    (((class color) (min-colors 88) (background dark))
+     :foreground "#f0ce43")
+    (t :inherit font-lock-variable-name-face))
+  "Face for edited status in VC-dir buffers.")
+
+(defface vc-dir-status-up-to-date
+  '((((class color) (min-colors 88) (background light))
+     :foreground "#315b00")
+    (((class color) (min-colors 88) (background dark))
+     :foreground "#70c900")
+    (t :inherit font-lock-builtin-face))
+  "Face for up-to-date status in VC-dir buffers.")
+
+(defface vc-dir-ignored
+  '((((class color) (min-colors 88) (background light))
+     :foreground "#56576d")
+    (((class color) (min-colors 88) (background dark))
+     :foreground "#93959b")
+    (t :inherit shadow))
+  "Face for ignored or empty values in VC-dir buffers.")
+
 ;; Used to store information for the files displayed in the directory buffer.
 ;; Each item displayed corresponds to one of these defstructs.
 (cl-defstruct (vc-dir-fileinfo
@@ -1126,11 +1198,11 @@ vc-dir-headers
 specific headers."
   (concat
    ;; First layout the common headers.
-   (propertize "VC backend : " 'face 'font-lock-type-face)
-   (propertize (format "%s\n" backend) 'face 'font-lock-variable-name-face)
-   (propertize "Working dir: " 'face 'font-lock-type-face)
+   (propertize "VC backend : " 'face 'vc-dir-header)
+   (propertize (format "%s\n" backend) 'face 'vc-dir-header-value)
+   (propertize "Working dir: " 'face 'vc-dir-header)
    (propertize (format "%s\n" (abbreviate-file-name dir))
-               'face 'font-lock-variable-name-face)
+               'face 'vc-dir-header-value)
    ;; Then the backend specific ones.
    (vc-call-backend backend 'dir-extra-headers dir)
    "\n"))
@@ -1386,9 +1458,9 @@ vc-default-dir-extra-headers
   ;; backend specific headers.
   ;; XXX: change this to return nil before the release.
   (concat
-   (propertize "Extra      : " 'face 'font-lock-type-face)
+   (propertize "Extra      : " 'face 'vc-dir-header)
    (propertize "Please add backend specific headers here.  It's easy!"
-	       'face 'font-lock-warning-face)))
+	       'face 'vc-dir-status-warning)))
 
 (defvar vc-dir-status-mouse-map
   (let ((map (make-sparse-keymap)))
@@ -1414,21 +1486,21 @@ vc-default-dir-printer
     (insert
      (propertize
       (format "%c" (if (vc-dir-fileinfo->marked fileentry) ?* ? ))
-      'face 'font-lock-type-face)
+      'face 'vc-dir-mark-indicator)
      "   "
      (propertize
       (format "%-20s" state)
-      'face (cond ((eq state 'up-to-date) 'font-lock-builtin-face)
-		  ((memq state '(missing conflict)) 'font-lock-warning-face)
+      'face (cond ((eq state 'up-to-date) 'vc-dir-status-up-to-date)
+		  ((memq state '(missing conflict)) 'vc-dir-status-warning)
 		  ((eq state 'edited) 'font-lock-constant-face)
-		  (t 'font-lock-variable-name-face))
+		  (t 'vc-dir-header-value))
       'mouse-face 'highlight
       'keymap vc-dir-status-mouse-map)
      " "
      (propertize
       (format "%s" filename)
       'face
-      (if isdir 'font-lock-comment-delimiter-face 'font-lock-function-name-face)
+      (if isdir 'vc-dir-directory 'vc-dir-file)
       'help-echo
       (if isdir
 	  "Directory\nVC operations can be applied to it\nmouse-3: Pop-up menu"
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index d00c2c2133..b4e6223769 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -462,7 +462,7 @@ vc-git-permissions-as-string
            (eq 0 (logand ?\111 (logxor old-perm new-perm))))
        "  "
      (if (eq 0 (logand ?\111 old-perm)) "+x" "-x"))
-  'face 'font-lock-type-face))
+  'face 'vc-dir-header))
 
 (defun vc-git-dir-printer (info)
   "Pretty-printer for the vc-dir-fileinfo structure."
@@ -474,20 +474,20 @@ vc-git-dir-printer
     (insert
      "  "
      (propertize (format "%c" (if (vc-dir-fileinfo->marked info) ?* ? ))
-                 'face 'font-lock-type-face)
+                 'face 'vc-dir-mark-indicator)
      "  "
      (propertize
       (format "%-12s" state)
-      'face (cond ((eq state 'up-to-date) 'font-lock-builtin-face)
-                  ((eq state '(missing conflict)) 'font-lock-warning-face)
-                  (t 'font-lock-variable-name-face))
+      'face (cond ((eq state 'up-to-date) 'vc-dir-status-up-to-date)
+                  ((eq state '(missing conflict)) 'vc-dir-status-warning)
+                  (t 'vc-dir-status-edited))
       'mouse-face 'highlight
       'keymap vc-dir-status-mouse-map)
      "  " (vc-git-permissions-as-string old-perm new-perm)
      "    "
      (propertize (vc-git-escape-file-name (vc-dir-fileinfo->name info))
-                 'face (if isdir 'font-lock-comment-delimiter-face
-                         'font-lock-function-name-face)
+                 'face (if isdir 'vc-dir-directory
+                         'vc-dir-file)
 		 'help-echo
 		 (if isdir
 		     "Directory\nVC operations can be applied to it\nmouse-3: Pop-up menu"
@@ -784,7 +784,7 @@ vc-git-dir-extra-headers
                   (mapconcat
                    (lambda (x)
                      (propertize x
-                                 'face 'font-lock-variable-name-face
+                                 'face 'vc-dir-header-value
                                  'mouse-face 'highlight
                                  'vc-git-hideable all-hideable
                                  'help-echo vc-git-stash-list-help
@@ -800,7 +800,7 @@ vc-git-dir-extra-headers
                   (mapconcat
                    (lambda (x)
                      (propertize x
-                                 'face 'font-lock-variable-name-face
+                                 'face 'vc-dir-header-value
                                  'mouse-face 'highlight
                                  'invisible t
                                  'vc-git-hideable t
@@ -812,31 +812,31 @@ vc-git-dir-extra-headers
                                'vc-git-hideable t))))))))
     ;; FIXME: maybe use a different face when nothing is stashed.
     (concat
-     (propertize "Branch     : " 'face 'font-lock-type-face)
+     (propertize "Branch     : " 'face 'vc-dir-header)
      (propertize branch
-		 'face 'font-lock-variable-name-face)
+		 'face 'vc-dir-header-value)
      (when remote-url
        (concat
 	"\n"
-	(propertize "Remote     : " 'face 'font-lock-type-face)
+	(propertize "Remote     : " 'face 'vc-dir-header)
 	(propertize remote-url
-		    'face 'font-lock-variable-name-face)))
+		    'face 'vc-dir-header-value)))
      ;; For now just a heading, key bindings can be added later for various bisect actions
      (when (file-exists-p (expand-file-name ".git/BISECT_START" (vc-git-root dir)))
-       (propertize  "\nBisect     : in progress" 'face 'font-lock-warning-face))
+       (propertize  "\nBisect     : in progress" 'face 'vc-dir-status-warning))
      (when (file-exists-p (expand-file-name ".git/rebase-apply" (vc-git-root dir)))
-       (propertize  "\nRebase     : in progress" 'face 'font-lock-warning-face))
+       (propertize  "\nRebase     : in progress" 'face 'vc-dir-status-warning))
      (if stash-list
          (concat
-          (propertize "\nStash      : " 'face 'font-lock-type-face)
+          (propertize "\nStash      : " 'face 'vc-dir-header)
           stash-button
           stash-string)
        (concat
-	(propertize "\nStash      : " 'face 'font-lock-type-face)
+	(propertize "\nStash      : " 'face 'vc-dir-header)
 	(propertize "Nothing stashed"
 		    'help-echo vc-git-stash-shared-help
                     'keymap vc-git-stash-shared-map
-		    'face 'font-lock-variable-name-face))))))
+		    'face 'vc-dir-ignored))))))
 
 (defun vc-git-branches ()
   "Return the existing branches, as a list of strings.
-- 
2.30.0


[-- Attachment #3: vc-dir-refashion-faces-dark.png --]
[-- Type: image/png, Size: 101670 bytes --]

[-- Attachment #4: vc-dir-refashion-faces-light.png --]
[-- Type: image/png, Size: 104395 bytes --]

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

end of thread, other threads:[~2021-02-10 13:32 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-07 11:42 bug#46358: 28.0.50; [PATCH] Add vc-dir faces; also apply them to vc-git Protesilaos Stavrou
2021-02-07 15:15 ` Eli Zaretskii
2021-02-07 16:15   ` Protesilaos Stavrou
2021-02-08  6:55     ` Lars Ingebrigtsen
2021-02-08 18:17       ` Juri Linkov
2021-02-08 23:24         ` Dmitry Gutov
2021-02-09  6:42           ` Protesilaos Stavrou
2021-02-09  9:19             ` Juri Linkov
2021-02-09 16:30               ` Protesilaos Stavrou
2021-02-09 17:46                 ` Protesilaos Stavrou
2021-02-10  1:48                   ` Dmitry Gutov
2021-02-10  4:06                     ` Protesilaos Stavrou
2021-02-10 13:32                       ` Dmitry Gutov
2021-02-08 15:54     ` Dmitry Gutov
2021-02-08 16:35       ` Protesilaos Stavrou
2021-02-08 23:33         ` Dmitry Gutov
2021-02-09  5:01           ` Protesilaos Stavrou
2021-02-09 13:05             ` Dmitry Gutov

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).