1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 10:30:25 -08:00

(vc-annotate-display): Replace optional arg `color-map' with

compulsory arg `ratio'.  Inline body of vc-annotate-time-span.
(vc-annotate-display-autoscale): Adjust call.
(vc-annotate-display-default): Adjust call.  Make arg compulsory.
Fix interactive spec.
(vc-annotate-time-span): Remove.
(vc-annotate-oldest-in-map): Rename from vc-annotate-car-last-cons.
(vc-annotate-mode-menu, vc-annotate-display-autoscale)
(vc-annotate-display-select): Use new name.
This commit is contained in:
Stefan Monnier 2005-12-28 20:13:47 +00:00
parent 0e0436d4a1
commit 97461c846c
2 changed files with 32 additions and 33 deletions

View file

@ -2922,19 +2922,19 @@ menu items."
'(vc-annotate-font-lock-keywords t))
(view-mode 1))
(defun vc-annotate-display-default (&optional ratio)
(defun vc-annotate-display-default (ratio)
"Display the output of \\[vc-annotate] using the default color range.
The color range is given by `vc-annotate-color-map', scaled by RATIO
if present. The current time is used as the offset."
(interactive "e")
The color range is given by `vc-annotate-color-map', scaled by RATIO.
The current time is used as the offset."
(interactive (progn (kill-local-variable 'vc-annotate-color-map) '(1.0)))
(message "Redisplaying annotation...")
(vc-annotate-display
(if ratio (vc-annotate-time-span vc-annotate-color-map ratio)))
(vc-annotate-display ratio)
(message "Redisplaying annotation...done"))
(defun vc-annotate-car-last-cons (a-list)
"Return car of last cons in association list A-LIST."
(caar (last a-list)))
(defun vc-annotate-oldest-in-map (color-map)
"Return the oldest time in the COLOR-MAP."
;; Since entries should be sorted, we can just use the last one.
(caar (last color-map)))
(defun vc-annotate-display-autoscale (&optional full)
"Highlight the output of \\[vc-annotate] using an autoscaled color map.
@ -2958,10 +2958,8 @@ cover the range from the oldest annotation to the newest."
(if (< date oldest)
(setq oldest date))))
(vc-annotate-display
(vc-annotate-time-span ;return the scaled colormap.
vc-annotate-color-map
(/ (- (if full newest current) oldest)
(vc-annotate-car-last-cons vc-annotate-color-map)))
(/ (- (if full newest current) oldest)
(vc-annotate-oldest-in-map vc-annotate-color-map))
(if full newest))
(message "Redisplaying annotation...done \(%s\)"
(if full
@ -2978,7 +2976,7 @@ cover the range from the oldest annotation to the newest."
(setq vc-annotate-display-mode nil)
(vc-annotate-display-select))
:style toggle :selected (null vc-annotate-display-mode)]
,@(let ((oldest-in-map (vc-annotate-car-last-cons vc-annotate-color-map)))
,@(let ((oldest-in-map (vc-annotate-oldest-in-map vc-annotate-color-map)))
(mapcar (lambda (element)
(let ((days (* element oldest-in-map)))
`[,(format "Span %.1f days" days)
@ -3024,23 +3022,19 @@ use; you may override this using the second optional arg MODE."
(cond ((null vc-annotate-display-mode)
;; The ratio is global, thus relative to the global color-map.
(kill-local-variable 'vc-annotate-color-map)
(vc-annotate-display-default vc-annotate-ratio))
;; One of the auto-scaling modes
(vc-annotate-display-default (or vc-annotate-ratio 1.0)))
;; One of the auto-scaling modes
((eq vc-annotate-display-mode 'scale)
(vc-annotate-display-autoscale))
((eq vc-annotate-display-mode 'fullscale)
(vc-annotate-display-autoscale t))
((numberp vc-annotate-display-mode) ; A fixed number of days lookback
(vc-annotate-display-default
(/ vc-annotate-display-mode (vc-annotate-car-last-cons
vc-annotate-color-map))))
(/ vc-annotate-display-mode
(vc-annotate-oldest-in-map vc-annotate-color-map))))
(t (error "No such display mode: %s"
vc-annotate-display-mode))))
;;;; (defun vc-BACKEND-annotate-command (file buffer) ...)
;;;; Execute "annotate" on FILE by using `call-process' and insert
;;;; the contents in BUFFER.
;;;###autoload
(defun vc-annotate (file rev &optional display-mode buf)
"Display the edit history of the current file using colors.
@ -3230,13 +3224,6 @@ revision."
(previous-line)
(line-number-at-pos))))))))
(defun vc-annotate-time-span (a-list span)
"Apply factor SPAN to the time-span of association list A-LIST.
Return the new alist."
;; Apply span to each car of every cons
(mapcar (lambda (elem) (cons (* (car elem) span) (cdr elem)))
a-list))
(defun vc-annotate-compcar (threshold a-list)
"Test successive cons cells of A-LIST against THRESHOLD.
Return the first cons cell with a car that is not less than THRESHOLD,
@ -3271,12 +3258,14 @@ or OFFSET if present."
(defvar vc-annotate-offset nil)
(defun vc-annotate-display (&optional color-map offset)
(defun vc-annotate-display (ratio &optional offset)
"Highlight `vc-annotate' output in the current buffer.
COLOR-MAP, if present, overrides `vc-annotate-color-map'.
RATIO, is the expansion that should be applied to `vc-annotate-color-map'.
The annotations are relative to the current time, unless overridden by OFFSET."
(if (and color-map (not (eq color-map vc-annotate-color-map)))
(set (make-local-variable 'vc-annotate-color-map) color-map))
(if (/= ratio 1.0)
(set (make-local-variable 'vc-annotate-color-map)
(mapcar (lambda (elem) (cons (* (car elem) ratio) (cdr elem)))
vc-annotate-color-map)))
(set (make-local-variable 'vc-annotate-offset) offset)
(font-lock-mode 1))