emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] Changes to emacs/lisp/vc.el


From: Stefan Monnier
Subject: [Emacs-diffs] Changes to emacs/lisp/vc.el
Date: Wed, 28 Dec 2005 20:13:48 +0000

Index: emacs/lisp/vc.el
diff -u emacs/lisp/vc.el:1.410 emacs/lisp/vc.el:1.411
--- emacs/lisp/vc.el:1.410      Wed Dec 28 18:47:12 2005
+++ emacs/lisp/vc.el    Wed Dec 28 20:13:47 2005
@@ -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))
 




reply via email to

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