unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* New commands for browsing diffs easily
@ 2006-04-11  8:16 Lars Magne Ingebrigtsen
  2006-04-11  8:43 ` Nick Roberts
  2006-04-11 18:24 ` Ted Zlatanov
  0 siblings, 2 replies; 23+ messages in thread
From: Lars Magne Ingebrigtsen @ 2006-04-11  8:16 UTC (permalink / raw)


I use `C-x v =' a lot, and one thing I've missed for ages is the
ability to just walk through the diff history.  That is, after seeing
that the diff in question wasn't really the one I was looking for, I
just want to see the diffs that comes before or after.

So this diff adds that.  I'm not quite sure that this is the best
implementation -- calling vc functions from diff mode might be a bit
naughty.  Or perhaps not.

I bound the commands to `M-C-n' and `M-C-p' as all the more likely key
strokes were already taken.

Index: ChangeLog
===================================================================
RCS file: /sources/emacs/emacs/lisp/ChangeLog,v
retrieving revision 1.9381
diff --unified -r1.9381 ChangeLog
--- ChangeLog	11 Apr 2006 00:08:56 -0000	1.9381
+++ ChangeLog	11 Apr 2006 08:13:24 -0000
@@ -1,3 +1,11 @@
+2006-04-11  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* vc.el (vc-buffer-revisions): New variable.
+	(vc-version-diff): Record the revisions.
+
+	* diff-mode.el (diff-display-previous-diff)
+	(diff-display-next-diff, diff-display-new-diff): New commands. 
+
 2006-04-10  Bill Wohler  <wohler@newt.com>
 
 	* custom.el (defcustom, custom-handle-keyword): Add
Index: diff-mode.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/diff-mode.el,v
retrieving revision 1.85
diff --unified -r1.85 diff-mode.el
--- diff-mode.el	21 Mar 2006 10:15:39 -0000	1.85
+++ diff-mode.el	11 Apr 2006 08:13:24 -0000
@@ -135,6 +135,8 @@
     ("R" . diff-reverse-direction)
     ("U" . diff-context->unified)
     ("C" . diff-unified->context)
+    ("\C-p" . diff-display-previous-diff)
+    ("\C-n" . diff-display-next-diff)
     ("q" . quit-window))
   "Basic keymap for `diff-mode', bound to various prefix keys.")
 
@@ -1376,6 +1378,30 @@
       (delete-file file1)
       (delete-file file2))))
 
+(defun diff-display-previous-diff ()
+  "Display the the diff between the two previous revisions."
+  (interactive)
+  (diff-display-new-diff vc-parent-buffer
+			 (vc-call previous-version
+				  (buffer-file-name vc-parent-buffer)
+				  (car vc-buffer-revisions))
+			 (car vc-buffer-revisions)))
+
+(defun diff-display-next-diff ()
+  "Display the the diff between the two next revisions."
+  (interactive)
+  (when (zerop (length (cadr vc-buffer-revisions)))
+    (error "At the end of the revision list"))
+  (diff-display-new-diff vc-parent-buffer
+			 (cadr vc-buffer-revisions)
+			 (vc-call next-version
+				  (buffer-file-name vc-parent-buffer)
+				  (cadr vc-buffer-revisions))))
+
+(defun diff-display-new-diff (parent-buffer rev1 rev2)
+  (set-buffer parent-buffer)
+  (vc-version-diff (buffer-file-name (current-buffer)) rev1 rev2))
+
 ;; provide the package
 (provide 'diff-mode)
 
Index: vc.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/vc.el,v
retrieving revision 1.414
diff --unified -r1.414 vc.el
--- vc.el	7 Feb 2006 16:59:01 -0000	1.414
+++ vc.el	11 Apr 2006 08:13:25 -0000
@@ -716,6 +716,8 @@
 (put 'vc-parent-buffer 'permanent-local t)
 (defvar vc-parent-buffer-name nil)
 (put 'vc-parent-buffer-name 'permanent-local t)
+(defvar vc-buffer-revisions nil)
+(put 'vc-buffer-revisions 'permanent-local t)
 
 (defvar vc-disable-async-diff nil
   "VC sets this to t locally to disable some async diff operations.
@@ -1755,6 +1757,8 @@
     ;; buffer should affect the diff command.
     (vc-diff-internal file rev1 rev2))
   (set-buffer "*vc-diff*")
+  ;; Record the revisions used to create this buffer
+  (set (make-local-variable 'vc-buffer-revisions) (list rev1 rev2))
   (if (and (zerop (buffer-size))
 	   (not (get-buffer-process (current-buffer))))
       (progn


-- 
(domestic pets only, the antidote for overdose, milk.)
  larsi@gnus.org * Lars Magne Ingebrigtsen

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2006-04-18 15:04 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-04-11  8:16 New commands for browsing diffs easily Lars Magne Ingebrigtsen
2006-04-11  8:43 ` Nick Roberts
2006-04-11  8:47   ` Lars Magne Ingebrigtsen
2006-04-11  8:58     ` Miles Bader
2006-04-11  9:06       ` Lars Magne Ingebrigtsen
2006-04-11  9:17         ` David Kastrup
2006-04-11  9:21           ` Lars Magne Ingebrigtsen
2006-04-11 14:33       ` Stefan Monnier
2006-04-11 14:45         ` Romain Francoise
2006-04-11 14:51           ` Lars Magne Ingebrigtsen
2006-04-11 15:39             ` Stefan Monnier
2006-04-11 15:44               ` Lars Magne Ingebrigtsen
2006-04-11 15:43             ` Romain Francoise
2006-04-11 18:24 ` Ted Zlatanov
2006-04-11 18:56   ` Stefan Monnier
2006-04-11 20:07     ` Ted Zlatanov
2006-04-11 20:20       ` Stefan Monnier
2006-04-12 14:54         ` meta-{next, previous}-error (was: New commands for browsing diffs easily) Ted Zlatanov
2006-04-12 16:25           ` meta-{next, previous}-error Lars Magne Ingebrigtsen
2006-04-13 18:53             ` Ted Zlatanov
2006-04-13 19:27               ` Romain Francoise
2006-04-14 16:15                 ` Richard Stallman
2006-04-18 15:04                   ` Ted Zlatanov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).