From: Lars Magne Ingebrigtsen <larsi@gnus.org>
Subject: New commands for browsing diffs easily
Date: Tue, 11 Apr 2006 10:16:21 +0200 [thread overview]
Message-ID: <m3lkucil2i.fsf@quimbies.gnus.org> (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
next reply other threads:[~2006-04-11 8:16 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-04-11 8:16 Lars Magne Ingebrigtsen [this message]
2006-04-11 8:43 ` New commands for browsing diffs easily 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m3lkucil2i.fsf@quimbies.gnus.org \
--to=larsi@gnus.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.