emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r103991: Add vc-annotate-goto-line.


From: Chong Yidong
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r103991: Add vc-annotate-goto-line.
Date: Sun, 24 Apr 2011 15:37:47 -0400
User-agent: Bazaar (2.3.1)

------------------------------------------------------------
revno: 103991
committer: Chong Yidong <address@hidden>
branch nick: trunk
timestamp: Sun 2011-04-24 15:37:47 -0400
message:
  Add vc-annotate-goto-line.
  * vc/vc-annotate.el (vc-annotate-goto-line): New command.  Based
  on a previous implementation by Juanma Barranquero (Bug#8366).
  (vc-annotate-mode-map): Bind it to RET.
modified:
  lisp/ChangeLog
  lisp/vc/vc-annotate.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2011-04-24 18:47:17 +0000
+++ b/lisp/ChangeLog    2011-04-24 19:37:47 +0000
@@ -1,3 +1,9 @@
+2011-04-24  Chong Yidong  <address@hidden>
+
+       * vc/vc-annotate.el (vc-annotate-goto-line): New command.  Based
+       on a previous implementation by Juanma Barranquero (Bug#8366).
+       (vc-annotate-mode-map): Bind it to RET.
+
 2011-04-24  Uday S Reddy  <address@hidden>  (tiny change)
 
        * progmodes/etags.el (next-file): Don't use set-buffer to change

=== modified file 'lisp/vc/vc-annotate.el'
--- a/lisp/vc/vc-annotate.el    2011-04-08 18:53:26 +0000
+++ b/lisp/vc/vc-annotate.el    2011-04-24 19:37:47 +0000
@@ -128,6 +128,8 @@
     (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.")
 
@@ -673,6 +675,36 @@
   ;; 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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]