X-Git-Url: http://git.hcoop.net/bpt/emacs.git/blobdiff_plain/8546720e6f25eb988e8215de6678798053031440..ab422c4d6899b1442cb6954c1829c1fb656b006c:/lisp/vc/vc-annotate.el diff --git a/lisp/vc/vc-annotate.el b/lisp/vc/vc-annotate.el index 271fce1242..8af488789d 100644 --- a/lisp/vc/vc-annotate.el +++ b/lisp/vc/vc-annotate.el @@ -1,6 +1,6 @@ ;;; vc-annotate.el --- VC Annotate Support -;; Copyright (C) 1997-1998, 2000-2011 Free Software Foundation, Inc. +;; Copyright (C) 1997-1998, 2000-2013 Free Software Foundation, Inc. ;; Author: Martin Lorentzson ;; Maintainer: FSF @@ -29,8 +29,7 @@ (require 'vc) ;;; Code: -(eval-when-compile - (require 'cl)) +(eval-when-compile (require 'cl-lib)) (defcustom vc-annotate-display-mode 'fullscale "Which mode to color the output of \\[vc-annotate] with by default." @@ -120,6 +119,7 @@ List of factors, used to expand/compress the time scale. See `vc-annotate'." (let ((m (make-sparse-keymap))) (define-key m "a" 'vc-annotate-revision-previous-to-line) (define-key m "d" 'vc-annotate-show-diff-revision-at-line) + (define-key m "=" 'vc-annotate-show-diff-revision-at-line) (define-key m "D" 'vc-annotate-show-changeset-diff-revision-at-line) (define-key m "f" 'vc-annotate-find-revision-at-line) (define-key m "j" 'vc-annotate-revision-at-line) @@ -128,6 +128,8 @@ List of factors, used to expand/compress the time scale. See `vc-annotate'." (define-key m "p" 'vc-annotate-prev-revision) (define-key m "w" 'vc-annotate-working-revision) (define-key m "v" 'vc-annotate-toggle-annotation-visibility) + (define-key m "v" 'vc-annotate-toggle-annotation-visibility) + (define-key m "\C-m" 'vc-annotate-goto-line) m) "Local keymap used for VC-Annotate mode.") @@ -192,7 +194,7 @@ The current time is used as the offset." (let ((bol (point)) (date (vc-call-backend vc-annotate-backend 'annotate-time)) (inhibit-read-only t)) - (assert (>= (point) bol)) + (cl-assert (>= (point) bol)) (put-text-property bol (point) 'invisible 'vc-annotate-annotation) date)) @@ -519,12 +521,12 @@ the file in question, search for the log entry required and move point." (car rev-at-line) t 1))))))) (defun vc-annotate-show-diff-revision-at-line-internal (filediff) - (if (not (equal major-mode 'vc-annotate-mode)) + (if (not (derived-mode-p 'vc-annotate-mode)) (message "Cannot be invoked outside of a vc annotate buffer") (let* ((rev-at-line (vc-annotate-extract-revision-at-line)) - (prev-rev nil) - (rev (car rev-at-line)) - (fname (cdr rev-at-line))) + (prev-rev nil) + (rev (car rev-at-line)) + (fname (cdr rev-at-line))) (if (not rev-at-line) (message "Cannot extract revision number from the current line") (setq prev-rev @@ -532,17 +534,15 @@ the file in question, search for the log entry required and move point." (if filediff fname nil) rev)) (if (not prev-rev) (message "Cannot diff from any revision prior to %s" rev) - (save-window-excursion - (vc-diff-internal - nil - ;; The value passed here should follow what - ;; `vc-deduce-fileset' returns. - (list vc-annotate-backend - (if filediff - (list fname) - nil)) - prev-rev rev)) - (switch-to-buffer "*vc-diff*")))))) + (vc-diff-internal + t + ;; The value passed here should follow what + ;; `vc-deduce-fileset' returns. + (list vc-annotate-backend + (if filediff + (list fname) + nil)) + prev-rev rev)))))) (defun vc-annotate-show-diff-revision-at-line () "Visit the diff of the revision at line from its previous revision." @@ -673,6 +673,36 @@ The annotations are relative to the current time, unless overridden by OFFSET." ;; Pretend to font-lock there were no matches. nil) +(defun vc-annotate-goto-line () + "Go to the line corresponding to the current VC Annotate line." + (interactive) + (unless (eq major-mode 'vc-annotate-mode) + (error "Not in a VC-Annotate buffer")) + (let ((line (save-restriction + (widen) + (line-number-at-pos))) + (rev vc-annotate-parent-rev)) + (pop-to-buffer + (or (and (buffer-live-p vc-parent-buffer) + vc-parent-buffer) + (and (file-exists-p vc-annotate-parent-file) + (find-file-noselect vc-annotate-parent-file)) + (error "File not found: %s" vc-annotate-parent-file))) + (save-restriction + (widen) + (goto-char (point-min)) + (forward-line (1- line)) + (recenter)) + ;; Issue a warning if the lines might be incorrect. + (cond + ((buffer-modified-p) + (message "Buffer modified; annotated line numbers may be incorrect")) + ((not (eq (vc-state buffer-file-name) 'up-to-date)) + (message "File is not up-to-date; annotated line numbers may be incorrect")) + ((not (equal rev (vc-working-revision buffer-file-name))) + (message "Annotations were for revision %s; line numbers may be incorrect" + rev))))) + (provide 'vc-annotate) ;;; vc-annotate.el ends here