Subject: bug#74352: 29.4; emerge-files with tramp + local file fails

From: Michael Albinus <[email-masked]>
Date: Sun, 17 Nov 2024 11:32:00 +0100

Jörg Sommer <[email-masked]> writes:

Hi Joerg,

>> The point is, that emerge calls the 'diff' program for either the file
>> itself (if local), or a local copy of the file (if remote). A consistent
>> solution is therefore to set a local default directory, like
>> 
>> --8<---------------cut here---------------start------------->8---
>>     (setq default-directory temporary-file-directory)
>> --8<---------------cut here---------------end--------------->8---
>> 
>> instead of your change. Would you like to check?
>
> This works.
>
> But in the context of *emerge-make-diff-list* it is not very apparent why
> *temporary-file-directory* is used. Maybe a comment should say that
> *emerge-files-internal* copied the files there by *file-local-copy*.

Sure, it doesn't hurt :-)

My patch is rather a proof of concept. It could be improved in all directions.

>> However, this won't be a complete solution. There are other places in
>> emerge.el, where the temporary buffer for calling 'diff' must have a
>> local default directory.
>
> Are you sure? I see only one usage of emerge-diff-program in emerge.el.

There is also emerge-diff3-program, used in emerge-make-diff3-list.

And there are also emerge-rcs-ci-program and emerge-rcs-co-program, used
at different places. But I don't know whether they need special care.

>> I'm not an emerge aficionado
>
> Out of curiosity: Is there a better tool?

ediff-files, ediff-directories and ediff-revision. Because I use them
all days, I've rebound some keys in my .emacs:

--8<---------------cut here---------------start------------->8---
(require 'dired)
(define-key dired-mode-map "=" 'ediff-files)
(define-key dired-mode-map "\M-=" 'ediff-directories)

(require 'vc)
(define-key vc-prefix-map "=" 'ediff-revision)
(setq ediff-diff-options "-a")

(add-hook 'vc-dir-mode-hook
	  (lambda () (define-key vc-dir-mode-map "=" 'ediff-revision)))
--8<---------------cut here---------------end--------------->8---

Best regards, Michael.