unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* New function: vc-ediff
@ 2011-03-10  4:20 Christoph Scholtes
  2011-03-10 16:00 ` Stefan Monnier
  2011-03-11  4:12 ` Michael Welsh Duggan
  0 siblings, 2 replies; 32+ messages in thread
From: Christoph Scholtes @ 2011-03-10  4:20 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 498 bytes --]

I started using ediff recently and was missing an easy way to compare 
the current buffer (or a file selected in vc-dir) with its latest 
revision in the repo. Basically, what vc-diff does, only using ediff 
instead.

Attached is a first cut at implementing this. Note, that this patch is 
just for review of the basic approach. I will add Changelog entries and 
(if applicable) manual documentation etc. later, if the approach has 
been reviewed.

Any comments are appreciated.

Thanks,
Christoph

[-- Attachment #2: vc-ediff_v1.patch --]
[-- Type: text/plain, Size: 3248 bytes --]

=== modified file 'lisp/vc/ediff-vers.el'
--- lisp/vc/ediff-vers.el	2011-01-25 04:08:28 +0000
+++ lisp/vc/ediff-vers.el	2011-03-10 04:03:04 +0000
@@ -59,6 +59,14 @@
       'vc-working-revision
     'vc-workfile-version))
 
+
+(defun ediff-revision-internal (rev1 rev2 &optional startup-hook)
+  ;; Call backend-specific ediff function. Uses `vc.el' or `rcs.el'
+  ;; depending on `ediff-version-control-package'."
+  (funcall
+   (intern (format "ediff-%S-internal" ediff-version-control-package))
+   rev1 rev2 startup-hook))
+
 ;; VC.el support
 
 (eval-when-compile

=== modified file 'lisp/vc/ediff.el'
--- lisp/vc/ediff.el	2011-01-25 04:08:28 +0000
+++ lisp/vc/ediff.el	2011-03-10 04:03:14 +0000
@@ -1408,8 +1408,7 @@
 (defun ediff-revision (&optional file startup-hooks)
   "Run Ediff by comparing versions of a file.
 The file is an optional FILE argument or the file entered at the prompt.
-Default: the file visited by the current buffer.
-Uses `vc.el' or `rcs.el' depending on `ediff-version-control-package'."
+Default: the file visited by the current buffer."
   ;; if buffer is non-nil, use that buffer instead of the current buffer
   (interactive "P")
   (if (not (stringp file))
@@ -1435,11 +1434,7 @@
 	   (format "Revision 2 to compare (default %s's current state): "
 		   (file-name-nondirectory file))))
     (ediff-load-version-control)
-    (funcall
-     (intern (format "ediff-%S-internal" ediff-version-control-package))
-     rev1 rev2 startup-hooks)
-    ))
-
+    (ediff-revision-internal rev1 rev2 startup-hooks)))
 
 ;;;###autoload
 (defalias 'erevision 'ediff-revision)

=== modified file 'lisp/vc/vc.el'
--- lisp/vc/vc.el	2011-03-07 08:56:30 +0000
+++ lisp/vc/vc.el	2011-03-10 04:04:32 +0000
@@ -1681,6 +1681,35 @@
 		      (called-interactively-p 'interactive))))
 
 ;;;###autoload
+(defun vc-ediff (historic &optional not-urgent)
+  "Display diffs between revisions of a file using ediff.
+Normally this compares the currently selected file with its
+working revision. With the prefix argument HISTORIC, it reads two revision
+designators specifying which revisions to compare.
+
+The optional argument NOT-URGENT non-nil means it is ok to say no
+to saving the buffer."
+  (interactive (list current-prefix-arg t))
+  (when buffer-file-name (vc-buffer-sync not-urgent))
+  (let* ((vc-fileset (vc-deduce-fileset not-urgent))
+         (files (cadr vc-fileset))
+         (first (car files)))
+      (cond
+       ;; FIXME: Only supports one selected file (for now?).
+       ;; Alternatively, we could spin off a separate ediff session
+       ;; for each of the selected files.
+       ((= (length files) 1)
+        (if historic
+            ;; Let user select revisions to compare.
+            (ediff-revision first)
+          (find-file first)
+          ;; With empty arguments, function compares latest version of
+          ;; current buffer's file with current buffer.
+          (ediff-revision-internal "" "")))
+       (t
+        (error "`vc-ediff' does not support selecting more than one file!")))))
+
+;;;###autoload
 (defun vc-root-diff (historic &optional not-urgent)
   "Display diffs between VC-controlled whole tree revisions.
 Normally, this compares the tree corresponding to the current


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

end of thread, other threads:[~2011-04-20 22:20 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-10  4:20 New function: vc-ediff Christoph Scholtes
2011-03-10 16:00 ` Stefan Monnier
2011-03-11  4:38   ` Christoph Scholtes
2011-03-11 20:15     ` Stefan Monnier
2011-03-12  8:38       ` Eli Zaretskii
2011-03-12 15:05         ` Christoph Scholtes
2011-03-12 17:49           ` Eli Zaretskii
2011-03-12 20:44         ` Stefan Monnier
2011-03-12 20:48           ` Eli Zaretskii
2011-03-12 21:27             ` Stefan Monnier
2011-03-19  2:24               ` Christoph Scholtes
2011-03-20  2:45                 ` Stefan Monnier
2011-03-22  4:46                   ` Christoph Scholtes
2011-03-27 16:03                     ` Christoph Scholtes
2011-03-27 20:58                     ` Stefan Monnier
2011-03-29  2:42                       ` Christoph Scholtes
2011-03-29 13:46                         ` Stefan Monnier
2011-03-30  3:02                           ` Christoph Scholtes
2011-04-08  1:16                         ` Christoph Scholtes
2011-04-17 19:04                           ` Christoph Scholtes
2011-04-20 17:39                             ` Stefan Monnier
2011-04-20 22:20                               ` Christoph Scholtes
2011-03-13 16:16             ` Uday S Reddy
2011-03-13 18:01               ` Eli Zaretskii
2011-03-13 21:35                 ` Stefan Monnier
2011-03-13 22:58                 ` Christoph Scholtes
2011-03-12 15:11       ` Christoph Scholtes
2011-03-12 21:25         ` Stefan Monnier
2011-03-11  4:12 ` Michael Welsh Duggan
2011-03-11  4:44   ` Christoph Scholtes
2011-03-11  7:46   ` Uday S Reddy
2011-03-11  8:16     ` martin rudalics

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).