diff options
| author | J.D. Smith | 2006-04-11 21:42:05 +0000 |
|---|---|---|
| committer | J.D. Smith | 2006-04-11 21:42:05 +0000 |
| commit | da7c8a122c76b86724d6d2b4c684af429d998fe3 (patch) | |
| tree | f7018c304abb396b11cc59e96e1d77bb05ac8dc9 | |
| parent | aa9addfa93a58c52f368d7ccc2bbcd178bcb067c (diff) | |
| download | emacs-da7c8a122c76b86724d6d2b4c684af429d998fe3.tar.gz emacs-da7c8a122c76b86724d6d2b4c684af429d998fe3.zip | |
(vc-annotate-display-mode): Made default 'fullscale.
(vc-annotate-color-map): New 18 element constant
value/saturation, rotating hue colormap, from red->blue.
(vc-annotate-mode-menu): "Default" -> "By Color Map Range".
(vc-annotate-display-select): Switch to annotate-mode elsewhere.
(vc-annotate): To avoid killing the required local variables,
set them before the end of `with-output-to-temp-buffer', and
after first switching to annotate-mode.
(vc-annotate-warp-version): Add buffer argument in goto-line to
ensure annotation, not source, is scrolled.
(vc-annotate-color-map): Added custom TTY color map for
8-color terminals, to use all of the colors in a sensible order.
256-color terminals work well with the standard map.
(vc-annotate-lines): Only strip the first color character if it
is "#", to allow for terminal-style named colors.
(vc-annotate-warp-version): Pass buf to `goto-line' to ensure
the correct buffer is scrolled.
| -rw-r--r-- | lisp/vc.el | 117 |
1 files changed, 79 insertions, 38 deletions
diff --git a/lisp/vc.el b/lisp/vc.el index b130aadb085..96d85e7b1e0 100644 --- a/lisp/vc.el +++ b/lisp/vc.el | |||
| @@ -584,9 +584,9 @@ See `run-hooks'." | |||
| 584 | :group 'vc | 584 | :group 'vc |
| 585 | :version "21.1") | 585 | :version "21.1") |
| 586 | 586 | ||
| 587 | (defcustom vc-annotate-display-mode nil | 587 | (defcustom vc-annotate-display-mode 'fullscale |
| 588 | "Which mode to color the output of \\[vc-annotate] with by default." | 588 | "Which mode to color the output of \\[vc-annotate] with by default." |
| 589 | :type '(choice (const :tag "Default" nil) | 589 | :type '(choice (const :tag "By Color Map Range" nil) |
| 590 | (const :tag "Scale to Oldest" scale) | 590 | (const :tag "Scale to Oldest" scale) |
| 591 | (const :tag "Scale Oldest->Newest" fullscale) | 591 | (const :tag "Scale Oldest->Newest" fullscale) |
| 592 | (number :tag "Specify Fractional Number of Days" | 592 | (number :tag "Specify Fractional Number of Days" |
| @@ -617,30 +617,64 @@ version control backend imposes itself." | |||
| 617 | 617 | ||
| 618 | ;; Annotate customization | 618 | ;; Annotate customization |
| 619 | (defcustom vc-annotate-color-map | 619 | (defcustom vc-annotate-color-map |
| 620 | '(( 20. . "#FFCC00") | 620 | (if (and (tty-display-color-p) (<= (display-color-cells) 8)) |
| 621 | ( 40. . "#FF6666") | 621 | ;; A custom sorted TTY colormap |
| 622 | ( 60. . "#FF6600") | 622 | (let* ((colors |
| 623 | ( 80. . "#FF3300") | 623 | (sort |
| 624 | (100. . "#FF00FF") | 624 | (delq nil |
| 625 | (120. . "#FF0000") | 625 | (mapcar (lambda (x) |
| 626 | (140. . "#CCCC00") | 626 | (if (not (or |
| 627 | (160. . "#CC00CC") | 627 | (string-equal (car x) "white") |
| 628 | (180. . "#BC8F8F") | 628 | (string-equal (car x) "black") )) |
| 629 | (200. . "#99CC00") | 629 | (car x))) |
| 630 | (220. . "#999900") | 630 | (tty-color-alist))) |
| 631 | (240. . "#7AC5CD") | 631 | (lambda (a b) |
| 632 | (260. . "#66CC00") | 632 | (cond |
| 633 | (280. . "#33CC33") | 633 | ((or (string-equal a "red") (string-equal b "blue")) t) |
| 634 | (300. . "#00CCFF") | 634 | ((or (string-equal b "red") (string-equal a "blue")) nil) |
| 635 | (320. . "#00CC99") | 635 | ((string-equal a "yellow") t) |
| 636 | (340. . "#0099FF")) | 636 | ((string-equal b "yellow") nil) |
| 637 | ((string-equal a "cyan") t) | ||
| 638 | ((string-equal b "cyan") nil) | ||
| 639 | ((string-equal a "green") t) | ||
| 640 | ((string-equal b "green") nil) | ||
| 641 | ((string-equal a "magenta") t) | ||
| 642 | ((string-equal b "magenta") nil) | ||
| 643 | (t (string< a b)))))) | ||
| 644 | (date 20.) | ||
| 645 | (delta (/ (- 360. date) (1- (length colors))))) | ||
| 646 | (mapcar (lambda (x) | ||
| 647 | (prog1 | ||
| 648 | (cons date x) | ||
| 649 | (setq date (+ date delta)))) colors)) | ||
| 650 | ;; Normal colormap: hue stepped from 0-240deg, value=1., saturation=0.75 | ||
| 651 | '(( 20. . "#FF3F3F") | ||
| 652 | ( 40. . "#FF6C3F") | ||
| 653 | ( 60. . "#FF993F") | ||
| 654 | ( 80. . "#FFC63F") | ||
| 655 | (100. . "#FFF33F") | ||
| 656 | (120. . "#DDFF3F") | ||
| 657 | (140. . "#B0FF3F") | ||
| 658 | (160. . "#83FF3F") | ||
| 659 | (180. . "#56FF3F") | ||
| 660 | (200. . "#3FFF56") | ||
| 661 | (220. . "#3FFF83") | ||
| 662 | (240. . "#3FFFB0") | ||
| 663 | (260. . "#3FFFDD") | ||
| 664 | (280. . "#3FF3FF") | ||
| 665 | (300. . "#3FC6FF") | ||
| 666 | (320. . "#3F99FF") | ||
| 667 | (340. . "#3F6CFF") | ||
| 668 | (360. . "#3F3FFF"))) | ||
| 637 | "Association list of age versus color, for \\[vc-annotate]. | 669 | "Association list of age versus color, for \\[vc-annotate]. |
| 638 | Ages are given in units of fractional days. Default is eighteen steps | 670 | Ages are given in units of fractional days. Default is eighteen |
| 639 | using a twenty day increment." | 671 | steps using a twenty day increment, from red to blue. For TTY |
| 672 | displays with 8 or fewer colors, the default is red to blue with | ||
| 673 | all other colors between (excluding black and white)." | ||
| 640 | :type 'alist | 674 | :type 'alist |
| 641 | :group 'vc) | 675 | :group 'vc) |
| 642 | 676 | ||
| 643 | (defcustom vc-annotate-very-old-color "#0046FF" | 677 | (defcustom vc-annotate-very-old-color "#3F3FFF" |
| 644 | "Color for lines older than the current color range in \\[vc-annotate]]." | 678 | "Color for lines older than the current color range in \\[vc-annotate]]." |
| 645 | :type 'string | 679 | :type 'string |
| 646 | :group 'vc) | 680 | :group 'vc) |
| @@ -2971,7 +3005,7 @@ cover the range from the oldest annotation to the newest." | |||
| 2971 | (easy-menu-define vc-annotate-mode-menu vc-annotate-mode-map | 3005 | (easy-menu-define vc-annotate-mode-menu vc-annotate-mode-map |
| 2972 | "VC Annotate Display Menu" | 3006 | "VC Annotate Display Menu" |
| 2973 | `("VC-Annotate" | 3007 | `("VC-Annotate" |
| 2974 | ["Default" (unless (null vc-annotate-display-mode) | 3008 | ["By Color Map Range" (unless (null vc-annotate-display-mode) |
| 2975 | (setq vc-annotate-display-mode nil) | 3009 | (setq vc-annotate-display-mode nil) |
| 2976 | (vc-annotate-display-select)) | 3010 | (vc-annotate-display-select)) |
| 2977 | :style toggle :selected (null vc-annotate-display-mode)] | 3011 | :style toggle :selected (null vc-annotate-display-mode)] |
| @@ -3016,8 +3050,6 @@ use; you may override this using the second optional arg MODE." | |||
| 3016 | (when buffer | 3050 | (when buffer |
| 3017 | (set-buffer buffer) | 3051 | (set-buffer buffer) |
| 3018 | (display-buffer buffer)) | 3052 | (display-buffer buffer)) |
| 3019 | (if (not vc-annotate-parent-rev) | ||
| 3020 | (vc-annotate-mode)) | ||
| 3021 | (cond ((null vc-annotate-display-mode) | 3053 | (cond ((null vc-annotate-display-mode) |
| 3022 | ;; The ratio is global, thus relative to the global color-map. | 3054 | ;; The ratio is global, thus relative to the global color-map. |
| 3023 | (kill-local-variable 'vc-annotate-color-map) | 3055 | (kill-local-variable 'vc-annotate-color-map) |
| @@ -3087,15 +3119,19 @@ colors. `vc-annotate-background' specifies the background color." | |||
| 3087 | ;; In case it had to be uniquified. | 3119 | ;; In case it had to be uniquified. |
| 3088 | (setq temp-buffer-name (buffer-name)))) | 3120 | (setq temp-buffer-name (buffer-name)))) |
| 3089 | (with-output-to-temp-buffer temp-buffer-name | 3121 | (with-output-to-temp-buffer temp-buffer-name |
| 3090 | (vc-call annotate-command file (get-buffer temp-buffer-name) rev)) | 3122 | (vc-call annotate-command file (get-buffer temp-buffer-name) rev) |
| 3091 | (with-current-buffer temp-buffer-name | 3123 | ;; we must setup the mode first, and then set our local |
| 3092 | (set (make-local-variable 'vc-annotate-backend) (vc-backend file)) | 3124 | ;; variables before the show-function is called at the exit of |
| 3093 | (set (make-local-variable 'vc-annotate-parent-file) file) | 3125 | ;; with-output-to-temp-buffer |
| 3094 | (set (make-local-variable 'vc-annotate-parent-rev) rev) | 3126 | (with-current-buffer temp-buffer-name |
| 3095 | (set (make-local-variable 'vc-annotate-parent-display-mode) | 3127 | (if (not (equal major-mode 'vc-annotate-mode)) |
| 3096 | display-mode)) | 3128 | (vc-annotate-mode)) |
| 3097 | 3129 | (set (make-local-variable 'vc-annotate-backend) (vc-backend file)) | |
| 3098 | (message "Annotating... done"))) | 3130 | (set (make-local-variable 'vc-annotate-parent-file) file) |
| 3131 | (set (make-local-variable 'vc-annotate-parent-rev) rev) | ||
| 3132 | (set (make-local-variable 'vc-annotate-parent-display-mode) | ||
| 3133 | display-mode))) | ||
| 3134 | (message "Annotating... done"))) | ||
| 3099 | 3135 | ||
| 3100 | (defun vc-annotate-prev-version (prefix) | 3136 | (defun vc-annotate-prev-version (prefix) |
| 3101 | "Visit the annotation of the version previous to this one. | 3137 | "Visit the annotation of the version previous to this one. |
| @@ -3191,7 +3227,8 @@ string, then it describes a revision number, so warp to that | |||
| 3191 | revision." | 3227 | revision." |
| 3192 | (if (not (equal major-mode 'vc-annotate-mode)) | 3228 | (if (not (equal major-mode 'vc-annotate-mode)) |
| 3193 | (message "Cannot be invoked outside of a vc annotate buffer") | 3229 | (message "Cannot be invoked outside of a vc annotate buffer") |
| 3194 | (let* ((oldline (line-number-at-pos)) | 3230 | (let* ((buf (current-buffer)) |
| 3231 | (oldline (line-number-at-pos)) | ||
| 3195 | (revspeccopy revspec) | 3232 | (revspeccopy revspec) |
| 3196 | (newrev nil)) | 3233 | (newrev nil)) |
| 3197 | (cond | 3234 | (cond |
| @@ -3218,10 +3255,10 @@ revision." | |||
| 3218 | (when newrev | 3255 | (when newrev |
| 3219 | (vc-annotate vc-annotate-parent-file newrev | 3256 | (vc-annotate vc-annotate-parent-file newrev |
| 3220 | vc-annotate-parent-display-mode | 3257 | vc-annotate-parent-display-mode |
| 3221 | (current-buffer)) | 3258 | buf) |
| 3222 | (goto-line (min oldline (progn (goto-char (point-max)) | 3259 | (goto-line (min oldline (progn (goto-char (point-max)) |
| 3223 | (previous-line) | 3260 | (previous-line) |
| 3224 | (line-number-at-pos)))))))) | 3261 | (line-number-at-pos))) buf))))) |
| 3225 | 3262 | ||
| 3226 | (defun vc-annotate-compcar (threshold a-list) | 3263 | (defun vc-annotate-compcar (threshold a-list) |
| 3227 | "Test successive cons cells of A-LIST against THRESHOLD. | 3264 | "Test successive cons cells of A-LIST against THRESHOLD. |
| @@ -3275,7 +3312,11 @@ The annotations are relative to the current time, unless overridden by OFFSET." | |||
| 3275 | (let* ((color (or (vc-annotate-compcar difference vc-annotate-color-map) | 3312 | (let* ((color (or (vc-annotate-compcar difference vc-annotate-color-map) |
| 3276 | (cons nil vc-annotate-very-old-color))) | 3313 | (cons nil vc-annotate-very-old-color))) |
| 3277 | ;; substring from index 1 to remove any leading `#' in the name | 3314 | ;; substring from index 1 to remove any leading `#' in the name |
| 3278 | (face-name (concat "vc-annotate-face-" (substring (cdr color) 1))) | 3315 | (face-name (concat "vc-annotate-face-" |
| 3316 | (if (string-equal | ||
| 3317 | (substring (cdr color) 0 1) "#") | ||
| 3318 | (substring (cdr color) 1) | ||
| 3319 | (cdr color)))) | ||
| 3279 | ;; Make the face if not done. | 3320 | ;; Make the face if not done. |
| 3280 | (face (or (intern-soft face-name) | 3321 | (face (or (intern-soft face-name) |
| 3281 | (let ((tmp-face (make-face (intern face-name)))) | 3322 | (let ((tmp-face (make-face (intern face-name)))) |