From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Lars Magne Ingebrigtsen Newsgroups: gmane.emacs.devel Subject: New commands for browsing diffs easily Date: Tue, 11 Apr 2006 10:16:21 +0200 Organization: Programmerer Ingebrigtsen Message-ID: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1144743460 30705 80.91.229.2 (11 Apr 2006 08:17:40 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 11 Apr 2006 08:17:40 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Apr 11 10:17:36 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1FTE44-0005uO-QP for ged-emacs-devel@m.gmane.org; Tue, 11 Apr 2006 10:17:33 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FTE43-00068I-VP for ged-emacs-devel@m.gmane.org; Tue, 11 Apr 2006 04:17:32 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FTE3h-00063q-I0 for emacs-devel@gnu.org; Tue, 11 Apr 2006 04:17:09 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FTE3g-00063G-Ly for emacs-devel@gnu.org; Tue, 11 Apr 2006 04:17:09 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FTE3g-000633-F3 for emacs-devel@gnu.org; Tue, 11 Apr 2006 04:17:08 -0400 Original-Received: from [80.91.229.2] (helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1FTE8V-0007Q5-40 for emacs-devel@gnu.org; Tue, 11 Apr 2006 04:22:07 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1FTE3X-0005nD-Sx for emacs-devel@gnu.org; Tue, 11 Apr 2006 10:17:00 +0200 Original-Received: from quimbies.gnus.org ([80.91.231.2]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 11 Apr 2006 10:16:59 +0200 Original-Received: from larsi by quimbies.gnus.org with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 11 Apr 2006 10:16:59 +0200 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: emacs-devel@gnu.org Original-To: emacs-devel@gnu.org Original-Lines: 108 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: quimbies.gnus.org Mail-Copies-To: never X-Now-Playing: Kate Bush's _Lionheart_: "Symphony In Blue" User-Agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux) Cancel-Lock: sha1:eQC+IeyLfRZdIWHg/elgOAV23nk= X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:52647 Archived-At: 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 + + * 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 * 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