[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
New commands for browsing diffs easily
From: |
Lars Magne Ingebrigtsen |
Subject: |
New commands for browsing diffs easily |
Date: |
Tue, 11 Apr 2006 10:16:21 +0200 |
User-agent: |
Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux) |
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 <address@hidden>
+
+ * 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 <address@hidden>
* 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.)
address@hidden * Lars Magne Ingebrigtsen
- New commands for browsing diffs easily,
Lars Magne Ingebrigtsen <=
- Re: New commands for browsing diffs easily, Nick Roberts, 2006/04/11
- Re: New commands for browsing diffs easily, Stefan Monnier, 2006/04/11
- Re: New commands for browsing diffs easily, Romain Francoise, 2006/04/11
- Re: New commands for browsing diffs easily, Lars Magne Ingebrigtsen, 2006/04/11
- Re: New commands for browsing diffs easily, Stefan Monnier, 2006/04/11