Mercurial > emacs
comparison lisp/vc.el @ 18246:3b4321d0ee7e
(vc-annotate-mode-variables): Init vc-annotate-mode-menu
and put it into vc-annotate-mode-map.
(vc-annotate-add-menu): Don't init vc-annotate-mode-menu,
just add the bindings to it. Display progress messages.
(vc-annotate-mode-menu): New defvar.
(vc-annotate-ratio): Move defvar, add initial value.
(vc-annotate-display-default): Display progress messages.
(vc-annotate-display): Use vc-annotate-color-map.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sat, 14 Jun 1997 17:29:10 +0000 |
parents | 238e30645d07 |
children | ffe9754664a2 |
comparison
equal
deleted
inserted
replaced
18245:045ae402e927 | 18246:3b4321d0ee7e |
---|---|
1982 | 1982 |
1983 ;; vc-annotate functionality (CVS only). | 1983 ;; vc-annotate functionality (CVS only). |
1984 (defvar vc-annotate-mode nil | 1984 (defvar vc-annotate-mode nil |
1985 "Variable indicating if VC-Annotate mode is active.") | 1985 "Variable indicating if VC-Annotate mode is active.") |
1986 | 1986 |
1987 (defvar vc-annotate-mode-map () | 1987 (defvar vc-annotate-mode-map nil |
1988 "Local keymap used for VC-Annotate mode.") | 1988 "Local keymap used for VC-Annotate mode.") |
1989 | |
1990 (defvar vc-annotate-mode-menu nil | |
1991 "Local keymap used for VC-Annotate mode's menu bar menu.") | |
1989 | 1992 |
1990 ;; Syntax Table | 1993 ;; Syntax Table |
1991 (defvar vc-annotate-mode-syntax-table nil | 1994 (defvar vc-annotate-mode-syntax-table nil |
1992 "Syntax table used in VC-Annotate mode buffers.") | 1995 "Syntax table used in VC-Annotate mode buffers.") |
1996 | |
1997 ;; Declare globally instead of additional parameter to | |
1998 ;; temp-buffer-show-function (not possible to pass more than one | |
1999 ;; parameter). | |
2000 (defvar vc-annotate-ratio nil) | |
1993 | 2001 |
1994 (defun vc-annotate-mode-variables () | 2002 (defun vc-annotate-mode-variables () |
1995 (if (not vc-annotate-mode-syntax-table) | 2003 (if (not vc-annotate-mode-syntax-table) |
1996 (progn (setq vc-annotate-mode-syntax-table (make-syntax-table)) | 2004 (progn (setq vc-annotate-mode-syntax-table (make-syntax-table)) |
1997 (set-syntax-table vc-annotate-mode-syntax-table))) | 2005 (set-syntax-table vc-annotate-mode-syntax-table))) |
1998 (if (not vc-annotate-mode-map) | 2006 (if (not vc-annotate-mode-map) |
1999 (setq vc-annotate-mode-map (make-sparse-keymap)))) | 2007 (setq vc-annotate-mode-map (make-sparse-keymap))) |
2008 (setq vc-annotate-mode-menu (make-sparse-keymap "Annotate")) | |
2009 (define-key vc-annotate-mode-map [menu-bar] | |
2010 (make-sparse-keymap "VC-Annotate")) | |
2011 (define-key vc-annotate-mode-map [menu-bar vc-annotate-mode] | |
2012 (cons "VC-Annotate" vc-annotate-mode-menu))) | |
2000 | 2013 |
2001 (defun vc-annotate-mode () | 2014 (defun vc-annotate-mode () |
2002 "Major mode for buffers displaying output from the CVS `annotate' command. | 2015 "Major mode for buffers displaying output from the CVS `annotate' command. |
2003 | 2016 |
2004 You can use the mode-specific menu to alter the time-span of the used | 2017 You can use the mode-specific menu to alter the time-span of the used |
2016 (vc-annotate-add-menu)) | 2029 (vc-annotate-add-menu)) |
2017 | 2030 |
2018 (defun vc-annotate-display-default (&optional event) | 2031 (defun vc-annotate-display-default (&optional event) |
2019 "Use the default color spectrum for VC Annotate mode." | 2032 "Use the default color spectrum for VC Annotate mode." |
2020 (interactive) | 2033 (interactive) |
2021 (vc-annotate-display (get-buffer (buffer-name)))) | 2034 (message "Redisplaying annotation...") |
2035 (vc-annotate-display (get-buffer (buffer-name))) | |
2036 (message "Redisplaying annotation...done")) | |
2022 | 2037 |
2023 (defun vc-annotate-add-menu () | 2038 (defun vc-annotate-add-menu () |
2024 "Adds the menu 'Annotate' to the menu bar in VC-Annotate mode." | 2039 "Adds the menu 'Annotate' to the menu bar in VC-Annotate mode." |
2025 (setq vc-annotate-mode-menu (make-sparse-keymap "Annotate")) | |
2026 (define-key vc-annotate-mode-menu [default] | 2040 (define-key vc-annotate-mode-menu [default] |
2027 '("Default" . vc-annotate-display-default)) | 2041 '("Default" . vc-annotate-display-default)) |
2028 (let ((menu-elements vc-annotate-menu-elements)) | 2042 (let ((menu-elements vc-annotate-menu-elements)) |
2029 (while menu-elements | 2043 (while menu-elements |
2030 (let* ((element (car menu-elements)) | 2044 (let* ((element (car menu-elements)) |
2036 (vector days) | 2050 (vector days) |
2037 (cons (format "Span %d days" | 2051 (cons (format "Span %d days" |
2038 days) | 2052 days) |
2039 `(lambda () | 2053 `(lambda () |
2040 ,(format "Use colors spanning %d days" days) | 2054 ,(format "Use colors spanning %d days" days) |
2041 (vc-annotate-display (get-buffer (buffer-name)) | 2055 (interactive) |
2042 (vc-annotate-time-span ,element))))))))) | 2056 (message "Redisplaying annotation...") |
2043 | 2057 (vc-annotate-display |
2044 (defvar vc-annotate-ratio) | 2058 (get-buffer (buffer-name)) |
2059 (vc-annotate-time-span vc-annotate-color-map ,element)) | |
2060 (message "Redisplaying annotation...done")))))))) | |
2045 | 2061 |
2046 ;;;###autoload | 2062 ;;;###autoload |
2047 (defun vc-annotate (ratio) | 2063 (defun vc-annotate (ratio) |
2048 "Display the result of the CVS `annotate' command using colors. | 2064 "Display the result of the CVS `annotate' command using colors. |
2049 New lines are displayed in red, old in blue. | 2065 New lines are displayed in red, old in blue. |
2096 (car (car args)))) | 2112 (car (car args)))) |
2097 | 2113 |
2098 (defun vc-annotate-display (buffer &optional color-map) | 2114 (defun vc-annotate-display (buffer &optional color-map) |
2099 "Do the VC-Annotate display in BUFFER using COLOR-MAP." | 2115 "Do the VC-Annotate display in BUFFER using COLOR-MAP." |
2100 | 2116 |
2117 ;; Handle the case of the global variable vc-annotate-ratio being | |
2118 ;; set. This variable is used to pass information from function | |
2119 ;; vc-annotate since it is not possible to use another parameter | |
2120 ;; (see temp-buffer-show-function). | |
2101 (if (and (not color-map) vc-annotate-ratio) | 2121 (if (and (not color-map) vc-annotate-ratio) |
2102 (setq color-map (vc-annotate-time-span color-map vc-annotate-ratio))) | 2122 ;; This will only be true if called from vc-annotate with ratio |
2123 ;; being non-nil. | |
2124 (setq color-map (vc-annotate-time-span vc-annotate-color-map | |
2125 vc-annotate-ratio))) | |
2103 | 2126 |
2104 ;; We need a list of months and their corresponding numbers. | 2127 ;; We need a list of months and their corresponding numbers. |
2105 (let* ((local-month-numbers | 2128 (let* ((local-month-numbers |
2106 '(("Jan" . 1) ("Feb" . 2) ("Mar" . 3) ("Apr" . 4) | 2129 '(("Jan" . 1) ("Feb" . 2) ("Mar" . 3) ("Apr" . 4) |
2107 ("May" . 5) ("Jun" . 6) ("Jul" . 7) ("Aug" . 8) | 2130 ("May" . 5) ("Jun" . 6) ("Jul" . 7) ("Aug" . 8) |