[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: New function: vc-ediff
From: |
Stefan Monnier |
Subject: |
Re: New function: vc-ediff |
Date: |
Sun, 27 Mar 2011 16:58:23 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) |
> I cleaned up the patch and also updated Changelogs, NEWS and manual.
> address@hidden vc-ediff
> +The function @code{vc-ediff} works similar to @code{vc-diff} and
> +provides a way to visually compare two revisions of a file an Ediff
^^^
in?
> +2011-03-22 Christoph Scholtes <address@hidden>
> +
> + * vc/ediff-vers.el (ediff-revision-internal): New
> + function. Factored out interface to ediff-revision without user
> + interaction.
> +
> + * vc/ediff.el: Require ediff-vers (for ediff-revision-internal).
> + (ediff-revision): Use new function ediff-revision-internal.
> +
> + * vc/vc.el (vc-ediff): New function. Provides functionality
> + similar to vc-diff using ediff backend.
No need to give any detail about a new function's purpose, just "New
function" is enough: the source code should explain the purpose (either
self-evidently or via comments&docstrings).
Also, remove the empty lines to make it clear that those three file-changes
go together.
> +(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))
I think this is not needed.
> === modified file 'lisp/vc/ediff.el'
> --- lisp/vc/ediff.el 2011-01-25 04:08:28 +0000
> +++ lisp/vc/ediff.el 2011-03-22 03:08:42 +0000
> @@ -120,7 +120,8 @@
> (eval-when-compile
> (require 'dired)
> (require 'ediff-util)
> - (require 'ediff-ptch))
> + (require 'ediff-ptch)
> + (require 'ediff-vers))
> ;; end pacifier
> (require 'ediff-init)
> @@ -1435,10 +1436,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)))
If we don't need ediff-revision-internal then I think the above changes
can also be dropped.
> +(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)
Problem with this code is that you depend on ediff-revision to get
the revision arguments. E.g. this doesn't provide completion.
IOW we should use more of vc-diff's code here.
> + (find-file first)
> + ;; With empty arguments, function compares latest version of
> + ;; current buffer's file with current buffer.
> + (ediff-revision-internal "" "")))
Call ediff-vc-internal here.
Stefan
- Re: New function: vc-ediff, (continued)
- Re: New function: vc-ediff, Stefan Monnier, 2011/03/12
- Re: New function: vc-ediff, Eli Zaretskii, 2011/03/12
- Re: New function: vc-ediff, Stefan Monnier, 2011/03/12
- Re: New function: vc-ediff, Christoph Scholtes, 2011/03/18
- Re: New function: vc-ediff, Stefan Monnier, 2011/03/19
- Re: New function: vc-ediff, Christoph Scholtes, 2011/03/22
- Re: New function: vc-ediff, Christoph Scholtes, 2011/03/27
- Re: New function: vc-ediff,
Stefan Monnier <=
- Re: New function: vc-ediff, Christoph Scholtes, 2011/03/28
- Re: New function: vc-ediff, Stefan Monnier, 2011/03/29
- Re: New function: vc-ediff, Christoph Scholtes, 2011/03/29
- Re: New function: vc-ediff, Uday S Reddy, 2011/03/13
- Re: New function: vc-ediff, Eli Zaretskii, 2011/03/13
- Re: New function: vc-ediff, Stefan Monnier, 2011/03/13
- Re: New function: vc-ediff, Christoph Scholtes, 2011/03/13
- Re: New function: vc-ediff, Christoph Scholtes, 2011/03/12
- Re: New function: vc-ediff, Stefan Monnier, 2011/03/12
Re: New function: vc-ediff, Michael Welsh Duggan, 2011/03/10