GNU bug report logs - #17808
24.4.50; vc-annotate colors

Previous Next

Package: emacs;

Reported by: Juri Linkov <juri <at> jurta.org>

Date: Thu, 19 Jun 2014 07:12:02 UTC

Severity: wishlist

Tags: patch

Fixed in version 24.4.50

Done: Juri Linkov <juri <at> jurta.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 17808 in the body.
You can then email your comments to 17808 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#17808; Package emacs. (Thu, 19 Jun 2014 07:12:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Juri Linkov <juri <at> jurta.org>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 19 Jun 2014 07:12:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.4.50; vc-annotate colors
Date: Thu, 19 Jun 2014 09:54:44 +0300
Severity: wishlist
Tags: patch

Currently vc-annotate uses dark background even when the default background
is light.  Would be nicer to have another option similar to the existing
`vc-annotate-background' that will define the default foreground
(instead of the default background) and put colors from color-map
on the background instead of the foreground:

=== modified file 'lisp/vc/vc-annotate.el'
--- lisp/vc/vc-annotate.el	2014-02-10 01:34:22 +0000
+++ lisp/vc/vc-annotate.el	2014-06-19 06:52:59 +0000
@@ -109,6 +109,16 @@ (defcustom vc-annotate-background "black
   :type '(choice (const :tag "Default background" nil) (color))
   :group 'vc)
 
+(defcustom vc-annotate-foreground nil
+  "Foreground color for \\[vc-annotate].
+When non-nil, the color range from `vc-annotate-color-map'
+is applied to background, and the color from this definition
+is applied to foreground.
+This option is in effect only when `vc-annotate-background' is nil."
+  :type '(choice (const :tag "Default foreground" nil) (color))
+  :version "24.5"
+  :group 'vc)
+
 (defcustom vc-annotate-menu-elements '(2 0.5 0.1 0.01)
   "Menu elements for the mode-specific menu of VC-Annotate mode.
 List of factors, used to expand/compress the time scale.  See `vc-annotate'."
@@ -347,7 +357,9 @@ (defun vc-annotate (file rev &optional d
 `vc-annotate-menu-elements' customizes the menu elements of the
 mode-specific menu.  `vc-annotate-color-map' and
 `vc-annotate-very-old-color' define the mapping of time to colors.
-`vc-annotate-background' specifies the background color."
+`vc-annotate-background' specifies the background color.
+`vc-annotate-foreground' specifies the foreground color
+when `vc-annotate-background' is nil."
   (interactive
    (save-current-buffer
      (vc-ensure-vc-buffer)
@@ -666,10 +678,15 @@ (defun vc-annotate-lines (limit)
                ;; Make the face if not done.
                (face (or (intern-soft face-name)
                          (let ((tmp-face (make-face (intern face-name))))
-                           (set-face-foreground tmp-face (cdr color))
-                           (when vc-annotate-background
-			     (set-face-background tmp-face
-						  vc-annotate-background))
+                           (cond
+                            (vc-annotate-background
+                             (set-face-foreground tmp-face (cdr color))
+                             (set-face-background tmp-face vc-annotate-background))
+                            (vc-annotate-foreground
+                             (set-face-foreground tmp-face vc-annotate-foreground)
+                             (set-face-background tmp-face (cdr color)))
+                            (t
+                             (set-face-foreground tmp-face (cdr color))))
                            tmp-face))))	; Return the face
           (put-text-property start end 'face face)))))
   ;; Pretend to font-lock there were no matches.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#17808; Package emacs. (Wed, 02 Jul 2014 00:19:01 GMT) Full text and rfc822 format available.

Message #8 received at 17808 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: 17808 <at> debbugs.gnu.org
Subject: Re: bug#17808: 24.4.50; vc-annotate colors
Date: Wed, 02 Jul 2014 02:18:27 +0300
> Currently vc-annotate uses dark background even when the default background
> is light.  Would be nicer to have another option similar to the existing
> `vc-annotate-background' that will define the default foreground
> (instead of the default background) and put colors from color-map
> on the background instead of the foreground:

Actually much cleaner would be to add a dedicated user option
that will define whether to apply the color map to the background
or to the foreground.  When applied to the background with the
default light background, colors need to be less saturated,
so the saturation is decreased from 75% to 20% for light backgrounds.
Also `vc-annotate-background' doesn't need the default value "black"
because the background will be dark on dark environments anyway.

=== modified file 'lisp/vc/vc-annotate.el'
--- lisp/vc/vc-annotate.el	2014-02-10 01:34:22 +0000
+++ lisp/vc/vc-annotate.el	2014-07-01 23:17:33 +0000
@@ -40,6 +40,22 @@ (defcustom vc-annotate-display-mode 'ful
 			 :value "20.5"))
   :group 'vc)
 
+(defcustom vc-annotate-background-mode
+  (not (or (eq (or frame-background-mode
+		   (frame-parameter nil 'background-mode)) 'dark)
+	   (and (tty-display-color-p) (<= (display-color-cells) 8))))
+  "Non-nil means `vc-annotate-color-map' is applied to the background.
+
+When non-nil, the color range from `vc-annotate-color-map' is applied
+to the background, while the foreground remains default.
+
+When nil, the color range from `vc-annotate-color-map' is applied
+to the foreground, and the color from the option `vc-annotate-background'
+is applied to the background."
+  :type 'boolean
+  :version "24.5"
+  :group 'vc)
+
 (defcustom vc-annotate-color-map
   (if (and (tty-display-color-p) (<= (display-color-cells) 8))
       ;; A custom sorted TTY colormap
@@ -71,25 +87,49 @@ (defcustom vc-annotate-color-map
 		  (prog1
 		      (cons date x)
 		    (setq date (+ date delta)))) colors))
-    ;; Normal colormap: hue stepped from 0-240deg, value=1., saturation=0.75
-    '(( 20. . "#FF3F3F")
-      ( 40. . "#FF6C3F")
-      ( 60. . "#FF993F")
-      ( 80. . "#FFC63F")
-      (100. . "#FFF33F")
-      (120. . "#DDFF3F")
-      (140. . "#B0FF3F")
-      (160. . "#83FF3F")
-      (180. . "#56FF3F")
-      (200. . "#3FFF56")
-      (220. . "#3FFF83")
-      (240. . "#3FFFB0")
-      (260. . "#3FFFDD")
-      (280. . "#3FF3FF")
-      (300. . "#3FC6FF")
-      (320. . "#3F99FF")
-      (340. . "#3F6CFF")
-      (360. . "#3F3FFF")))
+    (cond
+     ;; Normal colormap for background colors with dark foreground:
+     ;; hue stepped from 0-240deg, value=1., saturation=0.20
+     (vc-annotate-background-mode
+      '(( 20. . "#FFCCCC")
+	( 40. . "#FFD8CC")
+	( 60. . "#FFE4CC")
+	( 80. . "#FFF0CC")
+	(100. . "#FFFCCC")
+	(120. . "#F6FFCC")
+	(140. . "#EAFFCC")
+	(160. . "#DEFFCC")
+	(180. . "#D2FFCC")
+	(200. . "#CCFFD2")
+	(220. . "#CCFFDE")
+	(240. . "#CCFFEA")
+	(260. . "#CCFFF6")
+	(280. . "#CCFCFF")
+	(300. . "#CCF0FF")
+	(320. . "#CCE4FF")
+	(340. . "#CCD8FF")
+	(360. . "#CCCCFF")))
+     ;; Normal colormap for foreground colors on dark background:
+     ;; hue stepped from 0-240deg, value=1., saturation=0.75
+     (t
+      '(( 20. . "#FF3F3F")
+	( 40. . "#FF6C3F")
+	( 60. . "#FF993F")
+	( 80. . "#FFC63F")
+	(100. . "#FFF33F")
+	(120. . "#DDFF3F")
+	(140. . "#B0FF3F")
+	(160. . "#83FF3F")
+	(180. . "#56FF3F")
+	(200. . "#3FFF56")
+	(220. . "#3FFF83")
+	(240. . "#3FFFB0")
+	(260. . "#3FFFDD")
+	(280. . "#3FF3FF")
+	(300. . "#3FC6FF")
+	(320. . "#3F99FF")
+	(340. . "#3F6CFF")
+	(360. . "#3F3FFF")))))
   "Association list of age versus color, for \\[vc-annotate].
 Ages are given in units of fractional days.  Default is eighteen
 steps using a twenty day increment, from red to blue.  For TTY
@@ -98,12 +138,12 @@ (defcustom vc-annotate-color-map
   :type 'alist
   :group 'vc)
 
-(defcustom vc-annotate-very-old-color "#3F3FFF"
+(defcustom vc-annotate-very-old-color (if vc-annotate-background-mode "#CCCCFF" "#3F3FFF")
   "Color for lines older than the current color range in \\[vc-annotate]."
   :type 'string
   :group 'vc)
 
-(defcustom vc-annotate-background "black"
+(defcustom vc-annotate-background nil
   "Background color for \\[vc-annotate].
 Default color is used if nil."
   :type '(choice (const :tag "Default background" nil) (color))
@@ -347,7 +387,9 @@ (defun vc-annotate (file rev &optional d
 `vc-annotate-menu-elements' customizes the menu elements of the
 mode-specific menu.  `vc-annotate-color-map' and
 `vc-annotate-very-old-color' define the mapping of time to colors.
-`vc-annotate-background' specifies the background color."
+`vc-annotate-background' specifies the background color.
+`vc-annotate-background-mode' specifies whether the color map
+should be applied to the background or foreground."
   (interactive
    (save-current-buffer
      (vc-ensure-vc-buffer)
@@ -666,10 +708,13 @@ (defun vc-annotate-lines (limit)
                ;; Make the face if not done.
                (face (or (intern-soft face-name)
                          (let ((tmp-face (make-face (intern face-name))))
-                           (set-face-foreground tmp-face (cdr color))
-                           (when vc-annotate-background
-			     (set-face-background tmp-face
-						  vc-annotate-background))
+                           (cond
+                            (vc-annotate-background-mode
+                             (set-face-background tmp-face (cdr color)))
+                            (t
+                             (set-face-foreground tmp-face (cdr color))
+                             (when vc-annotate-background
+			       (set-face-background tmp-face vc-annotate-background))))
                            tmp-face))))	; Return the face
           (put-text-property start end 'face face)))))
   ;; Pretend to font-lock there were no matches.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#17808; Package emacs. (Wed, 02 Jul 2014 02:49:02 GMT) Full text and rfc822 format available.

Message #11 received at 17808 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Juri Linkov <juri <at> jurta.org>
Cc: 17808 <at> debbugs.gnu.org
Subject: Re: bug#17808: 24.4.50; vc-annotate colors
Date: Wed, 02 Jul 2014 05:47:51 +0300
> From: Juri Linkov <juri <at> jurta.org>
> Date: Wed, 02 Jul 2014 02:18:27 +0300
> 
> > Currently vc-annotate uses dark background even when the default background
> > is light.  Would be nicer to have another option similar to the existing
> > `vc-annotate-background' that will define the default foreground
> > (instead of the default background) and put colors from color-map
> > on the background instead of the foreground:
> 
> Actually much cleaner would be to add a dedicated user option
> that will define whether to apply the color map to the background
> or to the foreground.  When applied to the background with the
> default light background, colors need to be less saturated,
> so the saturation is decreased from 75% to 20% for light backgrounds.
> Also `vc-annotate-background' doesn't need the default value "black"
> because the background will be dark on dark environments anyway.

Did anyone think of just using the current default background color?
If not, why not?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#17808; Package emacs. (Thu, 03 Jul 2014 00:22:03 GMT) Full text and rfc822 format available.

Message #14 received at 17808 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 17808 <at> debbugs.gnu.org
Subject: Re: bug#17808: 24.4.50; vc-annotate colors
Date: Thu, 03 Jul 2014 02:31:03 +0300
>> > Currently vc-annotate uses dark background even when the default
>> > background is light.  Would be nicer to have another option similar
>> > to the existing `vc-annotate-background' that will define the
>> > default foreground (instead of the default background) and put
>> > colors from color-map on the background instead of the foreground:
>>
>> Actually much cleaner would be to add a dedicated user option
>> that will define whether to apply the color map to the background
>> or to the foreground.  When applied to the background with the
>> default light background, colors need to be less saturated,
>> so the saturation is decreased from 75% to 20% for light backgrounds.
>> Also `vc-annotate-background' doesn't need the default value "black"
>> because the background will be dark on dark environments anyway.
>
> Did anyone think of just using the current default background color?
> If not, why not?

Some colors from the current `vc-annotate-color-map' are
illegible when used for a foreground on a light background
(white by default).

But the last patch provides a palette where color saturation
is reduced from 75% to 20%, so the output looks nicely
for light backgrounds where related lines are grouped
using the same backgrounds like in the table from this post :-)

https://plus.google.com/+BrunoOliveira/posts/1mnVJcJqzVD




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#17808; Package emacs. (Fri, 04 Jul 2014 23:53:02 GMT) Full text and rfc822 format available.

Message #17 received at 17808 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 17808 <at> debbugs.gnu.org
Subject: Re: bug#17808: 24.4.50; vc-annotate colors
Date: Sat, 05 Jul 2014 02:48:35 +0300
> But the last patch provides a palette where color saturation
> is reduced from 75% to 20%, so the output looks nicely
> for light backgrounds where related lines are grouped
> using the same backgrounds like in the table from this post :-)
>
> https://plus.google.com/+BrunoOliveira/posts/1mnVJcJqzVD

To reduce saturation from 75% to 20% it was helpful to use
the function `color-hsv-to-rgb' that I found in the list archives.
There are several proposed versions:

http://lists.gnu.org/archive/html/emacs-devel/2010-11/msg00897.html
http://lists.gnu.org/archive/html/emacs-devel/2011-02/msg00738.html
http://debbugs.gnu.org/cgi/bugreport.cgi?bug=14074
http://lists.gnu.org/archive/html/emacs-devel/2014-01/msg01272.html

It seems that the latest produces the most exact results.

I wounder why this useful function still is not installed
in color.el?




Reply sent to Juri Linkov <juri <at> jurta.org>:
You have taken responsibility. (Tue, 08 Jul 2014 08:53:02 GMT) Full text and rfc822 format available.

Notification sent to Juri Linkov <juri <at> jurta.org>:
bug acknowledged by developer. (Tue, 08 Jul 2014 08:53:03 GMT) Full text and rfc822 format available.

Message #22 received at 17808-done <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: 17808-done <at> debbugs.gnu.org
Subject: Re: bug#17808: 24.4.50; vc-annotate colors
Date: Tue, 08 Jul 2014 11:51:43 +0300
Version: 24.4.50

> To reduce saturation from 75% to 20% it was helpful to use
> the function `color-hsv-to-rgb' that I found in the list archives.

Installed in the trunk.

PS: this code shows how `color-hsv-to-rgb' could be used
to reduce saturation:

(pp
 (mapcar
  (lambda (pair)
    (cons
     (car pair)
     (let ((hsv (apply 'color-rgb-to-hsv
                       (color-name-to-rgb
                        (cdr pair)))))
       (apply 'color-rgb-to-hex
              (color-hsv-to-rgb
               (nth 0 hsv) 0.20 (nth 2 hsv))))))
  '(( 20. . "#FF3F3F")
    ( 40. . "#FF6C3F")
    ( 60. . "#FF993F")
    ( 80. . "#FFC63F")
    (100. . "#FFF33F")
    (120. . "#DDFF3F")
    (140. . "#B0FF3F")
    (160. . "#83FF3F")
    (180. . "#56FF3F")
    (200. . "#3FFF56")
    (220. . "#3FFF83")
    (240. . "#3FFFB0")
    (260. . "#3FFFDD")
    (280. . "#3FF3FF")
    (300. . "#3FC6FF")
    (320. . "#3F99FF")
    (340. . "#3F6CFF")
    (360. . "#3F3FFF"))))




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 05 Aug 2014 11:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 9 years and 278 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.