unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* help: howto call ediff from elisp, interactive and multiple args ...
@ 2010-11-13 17:14 Peter Daum
  2010-11-13 19:16 ` Thierry Volpiatto
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Daum @ 2010-11-13 17:14 UTC (permalink / raw)
  To: help-gnu-emacs

Sorry, I couldn't find an appropriate subject line:

I have to compare many similar binary files and the best tool I could
find so far for this purpose is a combination of emacs, hexl-mode and
ediff. Because this involves far too much typing, I am trying to write a
little lisp function to set up everything. I already know several ways
how not to do this ;-)

(defun hexl-ediff (file1 file2)
  "hexl-find 2 files and run ediff on them"
  (interactive "fFile 1:" "fFile2:")
  (hexl-find-file file1)
  (let*
      (
       (buffer1 (last-buffer))
       (bn1 (buffer-name buffer1))
       (void (hexl-find-file file2))
       (buffer2 (last-buffer))
       (bn2 (buffer-name buffer2))
       (void (message "b1: %s b2: %s" bn1 bn2))
       )
    (ediff-buffers bn1 bn2)
    ))

There are several problems with this:

1) I could not find a way how to interactively call this with 2 files.
I'll get prompted for the 1st file and then I run into an error about
the wrong #args without any chance to enter the 2nd file name
2) More severe: I could not come up with any reliable way how to get the
names of the buffers that the calls to hexl-find-file created (the
desperate attempt with "last-buffer" will return "*Completions*" ;-)

Any ideas?

Regards,
                            Peter




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

* Re: help: howto call ediff from elisp, interactive and multiple args ...
  2010-11-13 17:14 Peter Daum
@ 2010-11-13 19:16 ` Thierry Volpiatto
  2010-11-13 19:37   ` Peter Daum
  0 siblings, 1 reply; 4+ messages in thread
From: Thierry Volpiatto @ 2010-11-13 19:16 UTC (permalink / raw)
  To: help-gnu-emacs

Peter Daum <gator_ml@yahoo.de> writes:

> Sorry, I couldn't find an appropriate subject line:
>
> I have to compare many similar binary files and the best tool I could
> find so far for this purpose is a combination of emacs, hexl-mode and
> ediff. Because this involves far too much typing, I am trying to write a
> little lisp function to set up everything. I already know several ways
> how not to do this ;-)
>
> (defun hexl-ediff (file1 file2)
>   "hexl-find 2 files and run ediff on them"
>   (interactive "fFile 1:" "fFile2:")
>   (hexl-find-file file1)
>   (let*
>       (
>        (buffer1 (last-buffer))
>        (bn1 (buffer-name buffer1))
>        (void (hexl-find-file file2))
>        (buffer2 (last-buffer))
>        (bn2 (buffer-name buffer2))
>        (void (message "b1: %s b2: %s" bn1 bn2))
>        )
>     (ediff-buffers bn1 bn2)
>     ))
>
> There are several problems with this:
>
> 1) I could not find a way how to interactively call this with 2 files.
> I'll get prompted for the 1st file and then I run into an error about
> the wrong #args without any chance to enter the 2nd file name
> 2) More severe: I could not come up with any reliable way how to get the
> names of the buffers that the calls to hexl-find-file created (the
> desperate attempt with "last-buffer" will return "*Completions*" ;-)
>
> Any ideas?


(defun hexl-ediff (file1 file2)
  "hexl-find 2 files and run ediff on them"
  (interactive "fFile 1: \nfFile2:")
  (let ((buffer1 (progn
                     (hexl-find-file file1)
                     (buffer-name (current-buffer))))
        (buffer2 (progn
                     (hexl-find-file file2)
                     (buffer-name (current-buffer)))))
    (ediff-buffers buffer1 buffer2)))

> Regards,
>                             Peter
>
>
>

-- 
A+ Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 




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

* Re: help: howto call ediff from elisp, interactive and multiple args ...
  2010-11-13 19:16 ` Thierry Volpiatto
@ 2010-11-13 19:37   ` Peter Daum
  0 siblings, 0 replies; 4+ messages in thread
From: Peter Daum @ 2010-11-13 19:37 UTC (permalink / raw)
  To: help-gnu-emacs

> Peter Daum <gator_ml@yahoo.de> wrote:
>> I have to compare many similar binary files and the best tool I could
>> find so far for this purpose is a combination of emacs, hexl-mode and
>> ediff. Because this involves far too much typing, I am trying to write a
>> little lisp function to set up everything. I already know several ways
>> how not to do this ;-)
[...]
On 2010-11-13 20:16, Thierry Volpiatto wrote:
> (defun hexl-ediff (file1 file2)
>   "hexl-find 2 files and run ediff on them"
>   (interactive "fFile 1: \nfFile2:")
>   (let ((buffer1 (progn
>                      (hexl-find-file file1)
>                      (buffer-name (current-buffer))))
>         (buffer2 (progn
>                      (hexl-find-file file2)
>                      (buffer-name (current-buffer)))))
>     (ediff-buffers buffer1 buffer2)))

Exactly what I was looking for and it actually works ;-)

Thanks a lot!
                   Peter




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

* Re: help: howto call ediff from elisp, interactive and multiple args ...
       [not found] <mailman.1.1289668514.26082.help-gnu-emacs@gnu.org>
@ 2010-11-13 20:13 ` Pascal J. Bourguignon
  0 siblings, 0 replies; 4+ messages in thread
From: Pascal J. Bourguignon @ 2010-11-13 20:13 UTC (permalink / raw)
  To: help-gnu-emacs

Peter Daum <gator_ml@yahoo.de> writes:

> Sorry, I couldn't find an appropriate subject line:
>
> I have to compare many similar binary files and the best tool I could
> find so far for this purpose is a combination of emacs, hexl-mode and
> ediff. Because this involves far too much typing, I am trying to write a
> little lisp function to set up everything. I already know several ways
> how not to do this ;-)
>
> (defun hexl-ediff (file1 file2)
>   "hexl-find 2 files and run ediff on them"
>   (interactive "fFile 1:" "fFile2:")
>   (hexl-find-file file1)
>   (let*
>       (
>        (buffer1 (last-buffer))
>        (bn1 (buffer-name buffer1))
>        (void (hexl-find-file file2))
>        (buffer2 (last-buffer))
>        (bn2 (buffer-name buffer2))
>        (void (message "b1: %s b2: %s" bn1 bn2))
>        )
>     (ediff-buffers bn1 bn2)
>     ))
>
> There are several problems with this:
>
> 1) I could not find a way how to interactively call this with 2 files.
> I'll get prompted for the 1st file and then I run into an error about
> the wrong #args without any chance to enter the 2nd file name

Have you read the documentation of interactive?

Do you know how to get it?

What word don't you understand in: 

    "To get several arguments, concatenate the individual strings,
    separating them by newline characters."

?



> 2) More severe: I could not come up with any reliable way how to get the
> names of the buffers that the calls to hexl-find-file created (the
> desperate attempt with "last-buffer" will return "*Completions*" ;-)

Have you read the documentation of ediff-buffers?

(Do you know how to get it?)

Now, a lot of functions taking buffers will accept buffer names as
buffer designators, in particular commands, so it wouldn't be wrong, but
you don't have to find the names. Just pass the buffers.

Also see:  (info "(elisp)Buffer Names")


After find-file, or hexl-find-file, the current-buffer will be the one.

(defun hexl-ediff (file1 file2)
  "hexl-find 2 files and run ediff on them"
  (interactive "fFile 1\nfFile2:")
  (ediff-buffers (progn (hexl-find-file file1)
                        (current-buffer))
                 (progn (hexl-find-file file2)
                        (current-buffer))))


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
A bad day in () is better than a good day in {}.


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

end of thread, other threads:[~2010-11-13 20:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.1.1289668514.26082.help-gnu-emacs@gnu.org>
2010-11-13 20:13 ` help: howto call ediff from elisp, interactive and multiple args Pascal J. Bourguignon
2010-11-13 17:14 Peter Daum
2010-11-13 19:16 ` Thierry Volpiatto
2010-11-13 19:37   ` Peter Daum

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