comparison lisp/vc.el @ 67882:59639203f09a

(vc-annotate-mode-map): Remove obsolete binding. (vc-annotate-mode-menu): Remove left-over redundant declaration. Correct the construction of span entries. Simplify. (vc-annotate-display-select): Fix the nil case. (vc-annotate): Remove obsolete (and now broken) code. (vc-annotate-extract-revision-at-line): Remove obsolete code. (vc-annotate-time-span): Remove unused arg `quantize'. Simplify.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Wed, 28 Dec 2005 18:47:12 +0000
parents f4a3c7808545
children e60b008e862d
comparison
equal deleted inserted replaced
67881:d9ec339158fe 67882:59639203f09a
657 :type '(repeat number) 657 :type '(repeat number)
658 :group 'vc) 658 :group 'vc)
659 659
660 (defvar vc-annotate-mode-map 660 (defvar vc-annotate-mode-map
661 (let ((m (make-sparse-keymap))) 661 (let ((m (make-sparse-keymap)))
662 (define-key m [menu-bar] (make-sparse-keymap "VC-Annotate"))
663 (define-key m "A" 'vc-annotate-revision-previous-to-line) 662 (define-key m "A" 'vc-annotate-revision-previous-to-line)
664 (define-key m "D" 'vc-annotate-show-diff-revision-at-line) 663 (define-key m "D" 'vc-annotate-show-diff-revision-at-line)
665 (define-key m "J" 'vc-annotate-revision-at-line) 664 (define-key m "J" 'vc-annotate-revision-at-line)
666 (define-key m "L" 'vc-annotate-show-log-revision-at-line) 665 (define-key m "L" 'vc-annotate-show-log-revision-at-line)
667 (define-key m "N" 'vc-annotate-next-version) 666 (define-key m "N" 'vc-annotate-next-version)
668 (define-key m "P" 'vc-annotate-prev-version) 667 (define-key m "P" 'vc-annotate-prev-version)
669 (define-key m "W" 'vc-annotate-workfile-version) 668 (define-key m "W" 'vc-annotate-workfile-version)
670 m) 669 m)
671 "Local keymap used for VC-Annotate mode.") 670 "Local keymap used for VC-Annotate mode.")
672
673 (defvar vc-annotate-mode-menu nil
674 "Local keymap used for VC-Annotate mode's menu bar menu.")
675 671
676 ;; Header-insertion hair 672 ;; Header-insertion hair
677 673
678 (defcustom vc-static-header-alist 674 (defcustom vc-static-header-alist
679 '(("\\.c\\'" . 675 '(("\\.c\\'" .
2962 (if (< date oldest) 2958 (if (< date oldest)
2963 (setq oldest date)))) 2959 (setq oldest date))))
2964 (vc-annotate-display 2960 (vc-annotate-display
2965 (vc-annotate-time-span ;return the scaled colormap. 2961 (vc-annotate-time-span ;return the scaled colormap.
2966 vc-annotate-color-map 2962 vc-annotate-color-map
2967 (/ (- (if full newest current) oldest) 2963 (/ (- (if full newest current) oldest)
2968 (vc-annotate-car-last-cons vc-annotate-color-map))) 2964 (vc-annotate-car-last-cons vc-annotate-color-map)))
2969 (if full newest)) 2965 (if full newest))
2970 (message "Redisplaying annotation...done \(%s\)" 2966 (message "Redisplaying annotation...done \(%s\)"
2971 (if full 2967 (if full
2972 (format "Spanned from %.1f to %.1f days old" 2968 (format "Spanned from %.1f to %.1f days old"
2983 (vc-annotate-display-select)) 2979 (vc-annotate-display-select))
2984 :style toggle :selected (null vc-annotate-display-mode)] 2980 :style toggle :selected (null vc-annotate-display-mode)]
2985 ,@(let ((oldest-in-map (vc-annotate-car-last-cons vc-annotate-color-map))) 2981 ,@(let ((oldest-in-map (vc-annotate-car-last-cons vc-annotate-color-map)))
2986 (mapcar (lambda (element) 2982 (mapcar (lambda (element)
2987 (let ((days (* element oldest-in-map))) 2983 (let ((days (* element oldest-in-map)))
2988 `([,(format "Span %.1f days" days) 2984 `[,(format "Span %.1f days" days)
2989 (unless (and (numberp vc-annotate-display-mode) 2985 (vc-annotate-display-select nil ,days)
2990 (= vc-annotate-display-mode ,days)) 2986 :style toggle :selected
2991 (vc-annotate-display-select nil ,days)) 2987 (eql vc-annotate-display-mode ,days) ]))
2992 :style toggle :selected
2993 (and (numberp vc-annotate-display-mode)
2994 (= vc-annotate-display-mode ,days)) ])))
2995 vc-annotate-menu-elements)) 2988 vc-annotate-menu-elements))
2996 ["Span ..." 2989 ["Span ..."
2997 (let ((days 2990 (vc-annotate-display-select
2998 (float (string-to-number 2991 nil (float (string-to-number (read-string "Span how many days? "))))]
2999 (read-string "Span how many days? ")))))
3000 (vc-annotate-display-select nil days)) t]
3001 "--" 2992 "--"
3002 ["Span to Oldest" 2993 ["Span to Oldest"
3003 (unless (eq vc-annotate-display-mode 'scale) 2994 (unless (eq vc-annotate-display-mode 'scale)
3004 (vc-annotate-display-select nil 'scale)) 2995 (vc-annotate-display-select nil 'scale))
3005 :style toggle :selected 2996 :style toggle :selected
3029 (set-buffer buffer) 3020 (set-buffer buffer)
3030 (display-buffer buffer)) 3021 (display-buffer buffer))
3031 (if (not vc-annotate-parent-rev) 3022 (if (not vc-annotate-parent-rev)
3032 (vc-annotate-mode)) 3023 (vc-annotate-mode))
3033 (cond ((null vc-annotate-display-mode) 3024 (cond ((null vc-annotate-display-mode)
3025 ;; The ratio is global, thus relative to the global color-map.
3026 (kill-local-variable 'vc-annotate-color-map)
3034 (vc-annotate-display-default vc-annotate-ratio)) 3027 (vc-annotate-display-default vc-annotate-ratio))
3035 ;; One of the auto-scaling modes 3028 ;; One of the auto-scaling modes
3036 ((eq vc-annotate-display-mode 'scale) 3029 ((eq vc-annotate-display-mode 'scale)
3037 (vc-annotate-display-autoscale)) 3030 (vc-annotate-display-autoscale))
3038 ((eq vc-annotate-display-mode 'fullscale) 3031 ((eq vc-annotate-display-mode 'fullscale)
3098 ;; revision, so we should update the buffer's name. 3091 ;; revision, so we should update the buffer's name.
3099 (if buf (with-current-buffer buf 3092 (if buf (with-current-buffer buf
3100 (rename-buffer temp-buffer-name t) 3093 (rename-buffer temp-buffer-name t)
3101 ;; In case it had to be uniquified. 3094 ;; In case it had to be uniquified.
3102 (setq temp-buffer-name (buffer-name)))) 3095 (setq temp-buffer-name (buffer-name))))
3103 (if (not (vc-find-backend-function vc-annotate-backend 'annotate-command))
3104 (error "Sorry, annotating is not implemented for %s"
3105 vc-annotate-backend))
3106 (with-output-to-temp-buffer temp-buffer-name 3096 (with-output-to-temp-buffer temp-buffer-name
3107 (vc-call annotate-command file (get-buffer temp-buffer-name) rev)) 3097 (vc-call annotate-command file (get-buffer temp-buffer-name) rev))
3108 (with-current-buffer temp-buffer-name 3098 (with-current-buffer temp-buffer-name
3109 (set (make-local-variable 'vc-annotate-backend) (vc-backend file)) 3099 (set (make-local-variable 'vc-annotate-backend) (vc-backend file))
3110 (set (make-local-variable 'vc-annotate-parent-file) file) 3100 (set (make-local-variable 'vc-annotate-parent-file) file)
3141 (vc-annotate-warp-version warp-rev))))) 3131 (vc-annotate-warp-version warp-rev)))))
3142 3132
3143 (defun vc-annotate-extract-revision-at-line () 3133 (defun vc-annotate-extract-revision-at-line ()
3144 "Extract the revision number of the current line." 3134 "Extract the revision number of the current line."
3145 ;; This function must be invoked from a buffer in vc-annotate-mode 3135 ;; This function must be invoked from a buffer in vc-annotate-mode
3146 (save-window-excursion
3147 (vc-ensure-vc-buffer)
3148 (setq vc-annotate-backend (vc-backend buffer-file-name)))
3149 (vc-call-backend vc-annotate-backend 'annotate-extract-revision-at-line)) 3136 (vc-call-backend vc-annotate-backend 'annotate-extract-revision-at-line))
3150 3137
3151 (defun vc-annotate-revision-at-line () 3138 (defun vc-annotate-revision-at-line ()
3152 "Visit the annotation of the version identified in the current line." 3139 "Visit the annotation of the version identified in the current line."
3153 (interactive) 3140 (interactive)
3241 (current-buffer)) 3228 (current-buffer))
3242 (goto-line (min oldline (progn (goto-char (point-max)) 3229 (goto-line (min oldline (progn (goto-char (point-max))
3243 (previous-line) 3230 (previous-line)
3244 (line-number-at-pos)))))))) 3231 (line-number-at-pos))))))))
3245 3232
3246 (defun vc-annotate-time-span (a-list span &optional quantize) 3233 (defun vc-annotate-time-span (a-list span)
3247 "Apply factor SPAN to the time-span of association list A-LIST. 3234 "Apply factor SPAN to the time-span of association list A-LIST.
3248 Return the new alist. 3235 Return the new alist."
3249 Optionally quantize to the factor of QUANTIZE."
3250 ;; Apply span to each car of every cons 3236 ;; Apply span to each car of every cons
3251 (if (not (eq nil a-list)) 3237 (mapcar (lambda (elem) (cons (* (car elem) span) (cdr elem)))
3252 (append (list (cons (* (car (car a-list)) span) 3238 a-list))
3253 (cdr (car a-list))))
3254 (vc-annotate-time-span (nthcdr (or quantize ; optional
3255 1) ; Default to cdr
3256 a-list) span quantize))))
3257 3239
3258 (defun vc-annotate-compcar (threshold a-list) 3240 (defun vc-annotate-compcar (threshold a-list)
3259 "Test successive cons cells of A-LIST against THRESHOLD. 3241 "Test successive cons cells of A-LIST against THRESHOLD.
3260 Return the first cons cell with a car that is not less than THRESHOLD, 3242 Return the first cons cell with a car that is not less than THRESHOLD,
3261 nil if no such cell exists." 3243 nil if no such cell exists."