help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Automating function with interactive args


From: Tassilo Horn
Subject: Re: Automating function with interactive args
Date: Fri, 27 Apr 2012 09:42:15 +0200
User-agent: Gnus/5.130004 (Ma Gnus v0.4) Emacs/24.1.50 (gnu/linux)

BDB <noemail@yahoo.com> writes:

> Tassilo Horn wrote:
>> --8<---------------cut here---------------start------------->8---
>> (require 'ediff)
>>
>> (defun my-ediff-revision-latest ()
>>   (interactive)
>>   (ediff-load-version-control)
>>   (funcall
>>    (intern (format "ediff-%S-internal" ediff-version-control-package))
>>    nil nil nil))
>> --8<---------------cut here---------------end--------------->8---
>
> This didn't work, however it seemed close (closer than the other
> example posted).  It brought up ediff with both windows pointing to
> the same HEAD version of the file, and gave an error "Removing old
> name: no such file or directory ..."

Hm...

> Anyone willing to help me understand the code here?  The format
> command is kind of like sprintf, right?

Yes.

> Why are you trying to call ediff-<value>-internal?  What's that?

I basically looked at the implementation of ediff-revision, and in the
end it just calls ediff-<value>-internal where value is usually vc.

I think the problem was that I provided nil for the files but they
should be "" for the defaults.  This one seems to work, and I also query
to save the buffer now like Drew.

--8<---------------cut here---------------start------------->8---
(defun my-ediff-revision-latest ()
   (interactive)
   (if (and (buffer-modified-p)
            (y-or-n-p (format "Buffer %s is modified. Save buffer? "
                              (buffer-name))))
       (save-buffer (current-buffer)))
   (ediff-load-version-control)
   (funcall
    (intern (format "ediff-%S-internal" ediff-version-control-package))
    "" "" nil))
--8<---------------cut here---------------end--------------->8---

Bye,
Tassilo




reply via email to

[Prev in Thread] Current Thread [Next in Thread]