comparison lisp/vc.el @ 46481:ddfd07bf63ec

(vc-default-comment-history): Hard code *vc*. This is because print-log always prints there now. (vc-annotate-font-lock-keywords): New var. (vc-annotate-mode): Use it. Set truncate-lines as well. (vc-annotate-display-select): Unify the two error reports. (vc-annotate-offset): New var. (vc-annotate-lines): New fun extracted from vc-annotate-display. (vc-annotate-display): Use it, via font-lock.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Tue, 16 Jul 2002 20:44:23 +0000
parents 386acc7f6c4d
children 021204d82a30
comparison
equal deleted inserted replaced
46480:5780b79b2269 46481:ddfd07bf63ec
4 4
5 ;; Author: FSF (see below for full credits) 5 ;; Author: FSF (see below for full credits)
6 ;; Maintainer: Andre Spiegel <spiegel@gnu.org> 6 ;; Maintainer: Andre Spiegel <spiegel@gnu.org>
7 ;; Keywords: tools 7 ;; Keywords: tools
8 8
9 ;; $Id: vc.el,v 1.331 2002/03/06 13:51:28 gerd Exp $ 9 ;; $Id: vc.el,v 1.332 2002/07/16 17:47:33 spiegel Exp $
10 10
11 ;; This file is part of GNU Emacs. 11 ;; This file is part of GNU Emacs.
12 12
13 ;; GNU Emacs is free software; you can redistribute it and/or modify 13 ;; GNU Emacs is free software; you can redistribute it and/or modify
14 ;; it under the terms of the GNU General Public License as published by 14 ;; it under the terms of the GNU General Public License as published by
1917 ;; use the buffer's coding system 1917 ;; use the buffer's coding system
1918 (let ((buf (find-buffer-visiting file))) 1918 (let ((buf (find-buffer-visiting file)))
1919 (if buf (with-current-buffer buf 1919 (if buf (with-current-buffer buf
1920 buffer-file-coding-system))) 1920 buffer-file-coding-system)))
1921 ;; otherwise, try to find one based on the file name 1921 ;; otherwise, try to find one based on the file name
1922 (car (find-operation-coding-system 'insert-file-contents 1922 (car (find-operation-coding-system 'insert-file-contents file))
1923 file))
1924 ;; and a final fallback 1923 ;; and a final fallback
1925 'undecided)) 1924 'undecided))
1926 1925
1927 ;;;###autoload 1926 ;;;###autoload
1928 (defun vc-version-other-window (rev) 1927 (defun vc-version-other-window (rev)
2509 (set-buffer-modified-p nil))))) 2508 (set-buffer-modified-p nil)))))
2510 2509
2511 (defun vc-default-comment-history (backend file) 2510 (defun vc-default-comment-history (backend file)
2512 "Return a string with all log entries stored in BACKEND for FILE." 2511 "Return a string with all log entries stored in BACKEND for FILE."
2513 (if (vc-find-backend-function backend 'print-log) 2512 (if (vc-find-backend-function backend 'print-log)
2514 (with-temp-buffer 2513 (with-current-buffer "*vc*"
2515 (vc-call print-log file) 2514 (vc-call print-log file)
2516 (vc-call wash-log file) 2515 (vc-call wash-log file)
2517 (buffer-string)))) 2516 (buffer-string))))
2518 2517
2519 (defun vc-default-wash-log (backend file) 2518 (defun vc-default-wash-log (backend file)
2945 ;; annotate-mode, which replaces it with the more sensible "span-to 2944 ;; annotate-mode, which replaces it with the more sensible "span-to
2946 ;; days", along with autoscaling support. 2945 ;; days", along with autoscaling support.
2947 (defvar vc-annotate-ratio nil "Global variable.") 2946 (defvar vc-annotate-ratio nil "Global variable.")
2948 (defvar vc-annotate-backend nil "Global variable.") 2947 (defvar vc-annotate-backend nil "Global variable.")
2949 2948
2949 (defconst vc-annotate-font-lock-keywords
2950 ;; The fontification is done by vc-annotate-lines instead of font-lock.
2951 '((vc-annotate-lines)))
2952
2950 (defun vc-annotate-get-backend (buffer) 2953 (defun vc-annotate-get-backend (buffer)
2951 "Return the backend matching \"Annotate\" buffer BUFFER. 2954 "Return the backend matching \"Annotate\" buffer BUFFER.
2952 Return nil if no match made. Associations are made based on 2955 Return nil if no match made. Associations are made based on
2953 `vc-annotate-buffers'." 2956 `vc-annotate-buffers'."
2954 (cdr (assoc buffer vc-annotate-buffers))) 2957 (cdr (assoc buffer vc-annotate-buffers)))
2957 "Major mode for output buffers of the `vc-annotate' command. 2960 "Major mode for output buffers of the `vc-annotate' command.
2958 2961
2959 You can use the mode-specific menu to alter the time-span of the used 2962 You can use the mode-specific menu to alter the time-span of the used
2960 colors. See variable `vc-annotate-menu-elements' for customizing the 2963 colors. See variable `vc-annotate-menu-elements' for customizing the
2961 menu items." 2964 menu items."
2965 (set (make-local-variable 'truncate-lines) t)
2966 (set (make-local-variable 'font-lock-defaults)
2967 '(vc-annotate-font-lock-keywords t))
2962 (vc-annotate-add-menu)) 2968 (vc-annotate-add-menu))
2963 2969
2964 (defun vc-annotate-display-default (&optional ratio) 2970 (defun vc-annotate-display-default (&optional ratio)
2965 "Display the output of \\[vc-annotate] using the default color range. 2971 "Display the output of \\[vc-annotate] using the default color range.
2966 The color range is given by `vc-annotate-color-map', scaled by RATIO 2972 The color range is given by `vc-annotate-color-map', scaled by RATIO
3063 (when buffer 3069 (when buffer
3064 (set-buffer buffer) 3070 (set-buffer buffer)
3065 (display-buffer buffer)) 3071 (display-buffer buffer))
3066 (if (not vc-annotate-mode) ; Turn on vc-annotate-mode if not done 3072 (if (not vc-annotate-mode) ; Turn on vc-annotate-mode if not done
3067 (vc-annotate-mode)) 3073 (vc-annotate-mode))
3068 (cond ((null vc-annotate-display-mode) (vc-annotate-display-default 3074 (cond ((null vc-annotate-display-mode)
3069 vc-annotate-ratio)) 3075 (vc-annotate-display-default vc-annotate-ratio))
3070 ((symbolp vc-annotate-display-mode) ; One of the auto-scaling modes 3076 ;; One of the auto-scaling modes
3071 (cond ((eq vc-annotate-display-mode 'scale) 3077 ((eq vc-annotate-display-mode 'scale)
3072 (vc-annotate-display-autoscale)) 3078 (vc-annotate-display-autoscale))
3073 ((eq vc-annotate-display-mode 'fullscale) 3079 ((eq vc-annotate-display-mode 'fullscale)
3074 (vc-annotate-display-autoscale t)) 3080 (vc-annotate-display-autoscale t))
3075 (t (error "No such display mode: %s"
3076 vc-annotate-display-mode))))
3077 ((numberp vc-annotate-display-mode) ; A fixed number of days lookback 3081 ((numberp vc-annotate-display-mode) ; A fixed number of days lookback
3078 (vc-annotate-display-default 3082 (vc-annotate-display-default
3079 (/ vc-annotate-display-mode (vc-annotate-car-last-cons 3083 (/ vc-annotate-display-mode (vc-annotate-car-last-cons
3080 vc-annotate-color-map)))) 3084 vc-annotate-color-map))))
3081 (t (error "Error in display mode select")))) 3085 (t (error "No such display mode: %s"
3086 vc-annotate-display-mode))))
3082 3087
3083 ;;;; (defun vc-BACKEND-annotate-command (file buffer) ...) 3088 ;;;; (defun vc-BACKEND-annotate-command (file buffer) ...)
3084 ;;;; Execute "annotate" on FILE by using `call-process' and insert 3089 ;;;; Execute "annotate" on FILE by using `call-process' and insert
3085 ;;;; the contents in BUFFER. 3090 ;;;; the contents in BUFFER.
3086 3091
3192 "Return the current time, encoded as fractional days." 3197 "Return the current time, encoded as fractional days."
3193 (vc-annotate-convert-time (current-time))) 3198 (vc-annotate-convert-time (current-time)))
3194 3199
3195 (defun vc-annotate-display (&optional color-map offset) 3200 (defun vc-annotate-display (&optional color-map offset)
3196 "Highlight `vc-annotate' output in the current buffer. 3201 "Highlight `vc-annotate' output in the current buffer.
3197 COLOR-MAP, if present, overrides `vc-annotate-color-map'. The 3202 COLOR-MAP, if present, overrides `vc-annotate-color-map'.
3198 annotations are relative to the current time, unless overridden by 3203 The annotations are relative to the current time, unless overridden by OFFSET.
3199 OFFSET.
3200 3204
3201 This function is obsolete, and has been replaced by 3205 This function is obsolete, and has been replaced by
3202 `vc-annotate-select'." 3206 `vc-annotate-display-select'."
3203 (save-excursion 3207 (if (and color-map (not (eq color-map vc-annotate-color-map)))
3204 (goto-char (point-min)) ; Position at the top of the buffer. 3208 (set (make-local-variable 'vc-annotate-color-map) color-map))
3205 ;; Delete old overlays 3209 (set (make-local-variable 'vc-annotate-offset) offset)
3206 (mapcar 3210 (font-lock-mode 1))
3207 (lambda (overlay) 3211
3208 (if (overlay-get overlay 'vc-annotation) 3212 (defvar vc-annotate-offset nil)
3209 (delete-overlay overlay))) 3213
3210 (overlays-in (point-min) (point-max))) 3214 (defun vc-annotate-lines (limit)
3211 (goto-char (point-min)) ; Position at the top of the buffer. 3215 (let (difference)
3212 (let (difference) 3216 (while (and (< (point) limit)
3213 (while (setq difference (vc-annotate-difference offset)) 3217 (setq difference (vc-annotate-difference vc-annotate-offset)))
3214 (let* 3218 (let* ((color (or (vc-annotate-compcar difference vc-annotate-color-map)
3215 ((color (or (vc-annotate-compcar 3219 (cons nil vc-annotate-very-old-color)))
3216 difference (or color-map vc-annotate-color-map)) 3220 ;; substring from index 1 to remove any leading `#' in the name
3217 (cons nil vc-annotate-very-old-color))) 3221 (face-name (concat "vc-annotate-face-" (substring (cdr color) 1)))
3218 ;; substring from index 1 to remove any leading `#' in the name 3222 ;; Make the face if not done.
3219 (face-name (concat "vc-annotate-face-" (substring (cdr color) 1))) 3223 (face (or (intern-soft face-name)
3220 ;; Make the face if not done. 3224 (let ((tmp-face (make-face (intern face-name))))
3221 (face (or (intern-soft face-name) 3225 (set-face-foreground tmp-face (cdr color))
3222 (let ((tmp-face (make-face (intern face-name)))) 3226 (if vc-annotate-background
3223 (set-face-foreground tmp-face (cdr color))
3224 (if vc-annotate-background
3225 (set-face-background tmp-face 3227 (set-face-background tmp-face
3226 vc-annotate-background)) 3228 vc-annotate-background))
3227 tmp-face))) ; Return the face 3229 tmp-face))) ; Return the face
3228 (point (point)) 3230 (point (point))
3229 overlay) 3231 overlay)
3230 (forward-line 1) 3232 (forward-line 1)
3231 (setq overlay (make-overlay point (point))) 3233 (put-text-property point (point) 'face face)))
3232 (overlay-put overlay 'face face) 3234 ;; Pretend to font-lock there were no matches.
3233 (overlay-put overlay 'vc-annotation t)))))) 3235 nil))
3234 3236
3235 ;; Collect back-end-dependent stuff here 3237 ;; Collect back-end-dependent stuff here
3236 3238
3237 (defalias 'vc-default-logentry-check 'ignore) 3239 (defalias 'vc-default-logentry-check 'ignore)
3238 3240