emacs-devel
[Top][All Lists]
Advanced

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

Re: Patch: new function process-file (call-process with file handlers)


From: Kai Grossjohann
Subject: Re: Patch: new function process-file (call-process with file handlers)
Date: Mon, 18 Oct 2004 08:44:53 +0200
User-agent: Gnus/5.110003 (No Gnus v0.3) Emacs/21.3.50 (gnu/linux)

Stefan Monnier <address@hidden> writes:

>> +(defun process-file (program &optional infile buffer display &rest args)
>> +  "Process files synchronously in a separate process.
>> +Similar to `call-process', but may invoke a file handler based on
>> +`default-directory'.  The current working directory of the
>> +subprocess is `default-directory'.
>> +
>> +File names in INFILE and BUFFER are handled normally, but file
>> +names in ARGS should be relative to `default-directory', as they
>> +are passed to the process verbatim.
>> +
>> +Some file handlers might not support all variants, for example
>> +they might behave as if DISPLAY was nil, regardless of the actual
>> +value passed."
>> +  (let ((fh (find-file-name-handler default-directory 'process-file)))
>> +    (if fh (apply fh 'process-file program infile buffer display args)
>> +      (apply 'call-process program infile buffer display args))))
>
> Looks good to me, except I'm not sure what INFILE should do.
>
> I guess we could use the following convention: if it is a relative file
> name, then it's a file on the remote host, otherwise, it's a file on the
> local host that should be passed "manually" by reading the file in a buffer
> and feeding it via the stdin pipe.

Well, INFILE should be fed to the stdin of the process, as for
call-process.  Why do we have to adopt a special convention, why can't
INFILE be relative to default-directory, as normal?

Hm.  Now I see: call-process doesn't grok file handlers for the INFILE
argument.  So that means that process-file should invoke
file-local-copy on the INFILE arg first.

But if a file handler is invoked, it could handle INFILE itself.  It
would be an optimization whether or not the contents are passed via a
buffer or directly via a file.

> Same thing for STDERR-FILE.

Right.  I guess process-file would need to wrap that one, too, for the
no-handler case.


I'm unsure whether this is the right time to install a change like
this.  OT1H, it's a new feature, OTOH, it helps to avoid defadvice and
that is desirable.

Kai





reply via email to

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