Mercurial > emacs
changeset 67885:e60b008e862d
(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.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Wed, 28 Dec 2005 20:13:47 +0000 |
parents | fb1d73360521 |
children | b98e23ab1402 |
files | lisp/ChangeLog lisp/vc.el |
diffstat | 2 files changed, 32 insertions(+), 33 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/ChangeLog Wed Dec 28 20:07:06 2005 +0000 +++ b/lisp/ChangeLog Wed Dec 28 20:13:47 2005 +0000 @@ -1,5 +1,15 @@ 2005-12-28 Stefan Monnier <monnier@iro.umontreal.ca> + * vc.el (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. + * vc.el (vc-annotate-mode-map): Remove obsolete binding. (vc-annotate-mode-menu): Remove left-over redundant declaration. Correct the construction of span entries. Simplify.
--- a/lisp/vc.el Wed Dec 28 20:07:06 2005 +0000 +++ b/lisp/vc.el Wed Dec 28 20:13:47 2005 +0000 @@ -2922,19 +2922,19 @@ '(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 @@ (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 @@ (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 @@ (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 @@ (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 @@ (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))