1919 |
(if buf (with-current-buffer buf |
(if buf (with-current-buffer buf |
1920 |
buffer-file-coding-system))) |
buffer-file-coding-system))) |
1921 |
;; otherwise, try to find one based on the file name |
;; otherwise, try to find one based on the file name |
1922 |
(car (find-operation-coding-system 'insert-file-contents |
(car (find-operation-coding-system 'insert-file-contents file)) |
|
file)) |
|
1923 |
;; and a final fallback |
;; and a final fallback |
1924 |
'undecided)) |
'undecided)) |
1925 |
|
|
2510 |
(defun vc-default-comment-history (backend file) |
(defun vc-default-comment-history (backend file) |
2511 |
"Return a string with all log entries stored in BACKEND for FILE." |
"Return a string with all log entries stored in BACKEND for FILE." |
2512 |
(if (vc-find-backend-function backend 'print-log) |
(if (vc-find-backend-function backend 'print-log) |
2513 |
(with-temp-buffer |
(with-current-buffer "*vc*" |
2514 |
(vc-call print-log file) |
(vc-call print-log file) |
2515 |
(vc-call wash-log file) |
(vc-call wash-log file) |
2516 |
(buffer-string)))) |
(buffer-string)))) |
2946 |
(defvar vc-annotate-ratio nil "Global variable.") |
(defvar vc-annotate-ratio nil "Global variable.") |
2947 |
(defvar vc-annotate-backend nil "Global variable.") |
(defvar vc-annotate-backend nil "Global variable.") |
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 |
|
|
2953 |
(defun vc-annotate-get-backend (buffer) |
(defun vc-annotate-get-backend (buffer) |
2954 |
"Return the backend matching \"Annotate\" buffer BUFFER. |
"Return the backend matching \"Annotate\" buffer BUFFER. |
2955 |
Return nil if no match made. Associations are made based on |
Return nil if no match made. Associations are made based on |
2962 |
You can use the mode-specific menu to alter the time-span of the used |
You can use the mode-specific menu to alter the time-span of the used |
2963 |
colors. See variable `vc-annotate-menu-elements' for customizing the |
colors. See variable `vc-annotate-menu-elements' for customizing the |
2964 |
menu items." |
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)) |
2968 |
(vc-annotate-add-menu)) |
(vc-annotate-add-menu)) |
2969 |
|
|
2970 |
(defun vc-annotate-display-default (&optional ratio) |
(defun vc-annotate-display-default (&optional ratio) |
3071 |
(display-buffer buffer)) |
(display-buffer buffer)) |
3072 |
(if (not vc-annotate-mode) ; Turn on vc-annotate-mode if not done |
(if (not vc-annotate-mode) ; Turn on vc-annotate-mode if not done |
3073 |
(vc-annotate-mode)) |
(vc-annotate-mode)) |
3074 |
(cond ((null vc-annotate-display-mode) (vc-annotate-display-default |
(cond ((null vc-annotate-display-mode) |
3075 |
vc-annotate-ratio)) |
(vc-annotate-display-default vc-annotate-ratio)) |
3076 |
((symbolp vc-annotate-display-mode) ; One of the auto-scaling modes |
;; One of the auto-scaling modes |
3077 |
(cond ((eq vc-annotate-display-mode 'scale) |
((eq vc-annotate-display-mode 'scale) |
3078 |
(vc-annotate-display-autoscale)) |
(vc-annotate-display-autoscale)) |
3079 |
((eq vc-annotate-display-mode 'fullscale) |
((eq vc-annotate-display-mode 'fullscale) |
3080 |
(vc-annotate-display-autoscale t)) |
(vc-annotate-display-autoscale t)) |
|
(t (error "No such display mode: %s" |
|
|
vc-annotate-display-mode)))) |
|
3081 |
((numberp vc-annotate-display-mode) ; A fixed number of days lookback |
((numberp vc-annotate-display-mode) ; A fixed number of days lookback |
3082 |
(vc-annotate-display-default |
(vc-annotate-display-default |
3083 |
(/ vc-annotate-display-mode (vc-annotate-car-last-cons |
(/ vc-annotate-display-mode (vc-annotate-car-last-cons |
3084 |
vc-annotate-color-map)))) |
vc-annotate-color-map)))) |
3085 |
(t (error "Error in display mode select")))) |
(t (error "No such display mode: %s" |
3086 |
|
vc-annotate-display-mode)))) |
3087 |
|
|
3088 |
;;;; (defun vc-BACKEND-annotate-command (file buffer) ...) |
;;;; (defun vc-BACKEND-annotate-command (file buffer) ...) |
3089 |
;;;; Execute "annotate" on FILE by using `call-process' and insert |
;;;; Execute "annotate" on FILE by using `call-process' and insert |
3199 |
|
|
3200 |
(defun vc-annotate-display (&optional color-map offset) |
(defun vc-annotate-display (&optional color-map offset) |
3201 |
"Highlight `vc-annotate' output in the current buffer. |
"Highlight `vc-annotate' output in the current buffer. |
3202 |
COLOR-MAP, if present, overrides `vc-annotate-color-map'. The |
COLOR-MAP, if present, overrides `vc-annotate-color-map'. |
3203 |
annotations are relative to the current time, unless overridden by |
The annotations are relative to the current time, unless overridden by OFFSET. |
|
OFFSET. |
|
3204 |
|
|
3205 |
This function is obsolete, and has been replaced by |
This function is obsolete, and has been replaced by |
3206 |
`vc-annotate-select'." |
`vc-annotate-display-select'." |
3207 |
(save-excursion |
(if (and color-map (not (eq color-map vc-annotate-color-map))) |
3208 |
(goto-char (point-min)) ; Position at the top of the buffer. |
(set (make-local-variable 'vc-annotate-color-map) color-map)) |
3209 |
;; Delete old overlays |
(set (make-local-variable 'vc-annotate-offset) offset) |
3210 |
(mapcar |
(font-lock-mode 1)) |
3211 |
(lambda (overlay) |
|
3212 |
(if (overlay-get overlay 'vc-annotation) |
(defvar vc-annotate-offset nil) |
3213 |
(delete-overlay overlay))) |
|
3214 |
(overlays-in (point-min) (point-max))) |
(defun vc-annotate-lines (limit) |
3215 |
(goto-char (point-min)) ; Position at the top of the buffer. |
(let (difference) |
3216 |
(let (difference) |
(while (and (< (point) limit) |
3217 |
(while (setq difference (vc-annotate-difference offset)) |
(setq difference (vc-annotate-difference vc-annotate-offset))) |
3218 |
(let* |
(let* ((color (or (vc-annotate-compcar difference vc-annotate-color-map) |
3219 |
((color (or (vc-annotate-compcar |
(cons nil vc-annotate-very-old-color))) |
3220 |
difference (or color-map vc-annotate-color-map)) |
;; substring from index 1 to remove any leading `#' in the name |
3221 |
(cons nil vc-annotate-very-old-color))) |
(face-name (concat "vc-annotate-face-" (substring (cdr color) 1))) |
3222 |
;; substring from index 1 to remove any leading `#' in the name |
;; Make the face if not done. |
3223 |
(face-name (concat "vc-annotate-face-" (substring (cdr color) 1))) |
(face (or (intern-soft face-name) |
3224 |
;; Make the face if not done. |
(let ((tmp-face (make-face (intern face-name)))) |
3225 |
(face (or (intern-soft face-name) |
(set-face-foreground tmp-face (cdr color)) |
3226 |
(let ((tmp-face (make-face (intern face-name)))) |
(if vc-annotate-background |
|
(set-face-foreground tmp-face (cdr color)) |
|
|
(if vc-annotate-background |
|
3227 |
(set-face-background tmp-face |
(set-face-background tmp-face |
3228 |
vc-annotate-background)) |
vc-annotate-background)) |
3229 |
tmp-face))) ; Return the face |
tmp-face))) ; Return the face |
3230 |
(point (point)) |
(point (point)) |
3231 |
overlay) |
overlay) |
3232 |
(forward-line 1) |
(forward-line 1) |
3233 |
(setq overlay (make-overlay point (point))) |
(put-text-property point (point) 'face face))) |
3234 |
(overlay-put overlay 'face face) |
;; Pretend to font-lock there were no matches. |
3235 |
(overlay-put overlay 'vc-annotation t)))))) |
nil)) |
3236 |
|
|
3237 |
;; Collect back-end-dependent stuff here |
;; Collect back-end-dependent stuff here |
3238 |
|
|