bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Annotate Patches to vc.el


From: John-David Smith
Subject: Annotate Patches to vc.el
Date: Fri, 08 Jun 2001 01:32:30 -0400

;; Id: vc.el,v 1.256 1999/10/02 10:53:18 *** with changes

I have been mucking around with the above named vc.el a bit to clean up
the annotation coloring support (try C-x v g).  I think this version is current
as of Emacs 20.7.

My motivation was the inconsistent and sub-optimal coloring for the basic menu
choices available (Span n days).  This is especially severe if the modification
times are tightly clustered some time in the past.  For example, the displayed
annotation of a file which had an intense month of commits over a year ago, and
nothing since, is almost all blue: the dynamic range utilized is tiny.  

To solve this problem, I added two new options to the VC-annotate menu: 

        Span to Oldest
        Span Oldest->Newest

The first simply scales the colormap so that the oldest annotation will
just line up with the last color (like a dynamic "number of days" span,
based on the file's oldest annotation date itself).  The option I really
like is the latter, which scales from the oldest date to the newest date
in the annotation list, covering the full range of days.  So whatever
was "hot" back when development wound down would still be red, and more
importantly, the dynamic range is maximized (most colors shown -- you
always get blue...red).

I also met a few inconsistencies.  Since cvs annotate includes only days (no
times), the highest 16 bits of the time-since-1970 encoding of midnight on that
day are used.  For the current time, however, whatever falls out of (car
(current-time)) was used.  This is usually no problem, except for very recent or
short lived annotation ranges, which span only a few days.  Then, it's quite
possible that, though the day has not changed, the nearest 2^16 second unit of
time (~3/4 of a day) *has*, and you don't get the expected result that
"modifications done today are most recent (and red)".  The solution to this was
to encode midnight of the current day as the basic "current" offset, the same as
for the annotations.

Since I needed to scan through the annotate buffer *twice* for the
auto-scaling modes (once to gather the oldest and newest annotation
date, and once to apply the overlays), I broke out the date search logic
into its own function.  

I also made a customize variable for picking which mode you'd like to use to
color annotations by default.  To accomplish this I added a redirector
vc-annotate-display-select which checks the mode and calls the correct
function.  This is now the temp-buffer-show-function for the annotation buffer,
(leaving vc-annotate-display more freedom -- no `buffer' argument required, for
one).

The customize variable is interepreted as "number of days to display" if
it's an integer (other possibilities are nil, 'scale and 'fullscale).  I changed
the meaning of "Default" to be whatever the customize variable was setup to be,
so you could go back if you changed it and don't remember.  What used to be
called "Default" I changed to "Standard"... i.e. purely based on the colormap
mapping, with no scaling.

There is some duplication of function here, since changing the overall date span
of the user-settable vc-annotate-colormap doesn't change the display of the
scaled modes (though changing it from a linear colormap certainly would).  I
think this is an acceptable compromise, though, since it will work well with
whatever colormaps people choose, while using the ratio directly will work fine
in the "Standard" modes.

Are these (reasonably large) patches to vc.el possible for inclusion in a
distributed version of GNU Emacs?  How would they best be submitted?  Thanks for
your help.

Cheers,

JD Smith



reply via email to

[Prev in Thread] Current Thread [Next in Thread]