[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: shell-command-on-region doesn't run remotely
From: |
Dan Davison |
Subject: |
Re: shell-command-on-region doesn't run remotely |
Date: |
Sat, 20 Feb 2010 12:02:03 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) |
Michael Albinus <address@hidden> writes:
> Dan Davison <address@hidden> writes:
>
>> I'd like to use shell-command-on-region with tramp, so that the shell
>> process is running remotely. However, it seems that although
>> shell-command behaves in this way, shell-command-on-region does
>> not.
>
> `shell-command-on-region' is not a magic file name operation like
> `shell-command'. Internally, it calls `call-process-region', which isn't
> magic neither. See (info "(elisp)Magic File Names")
>
>> I'm curious as to whether this is intended behaviour or a bug, and would
>> appreciate any suggestions for a nice way to implement my own version of
>> shell-command-on-region (using tramp technology?) that does run
>> remotely.
>>
>> But maybe I'm getting something wrong, as the above behaviour seems to
>> contradict this 2008 thread on tramp-devel
>>
>> http://lists.gnu.org/archive/html/tramp-devel/2008-05/msg00025.html
>>
>> and also this Jan 2009 thread on help-gnu-emacs
>>
>> http://lists.gnu.org/archive/html/help-gnu-emacs/2009-01/msg00487.html
>
> I've proposed to make `call-process and `call-process-region'
> magic. This was rejected by the Emacs maintainers (with good
> reasons). However, there still exists a prototype implementation for
> `call-process-region' in Tramp. That's what you see here.
>
> So the best solution might be to request, that `shell-command-on-region'
> shall be a magic operation like `shell-command'. It won't find its way
> into Emacs 23.2 (it's already in feature freeze), but it might be
> accepted for a later release.
>
> As workaround, you could try to use `tramp-handle-call-process-region'
> (but I cannot guarantee it stays forever in Tramp). Something like this:
>
> (defadvice call-process-region
> (around tramp-advice-call-process-region activate)
> "Invoke `tramp-handle-call-process-region' for Tramp files."
> (if (file-remote-p default-directory)
> (setq ad-return-value
> (apply 'tramp-handle-call-process-region (ad-get-args 0)))
> ad-do-it))
>
> I haven't tested it, 'though.
Michael --
Thanks very much for the help. I'm finding that the above advice does
not have the desired effect (the shell process still runs
locally). However, it does work if I alter
tramp-handle-call-process-region as follows:
;; (apply 'call-process program tmpfile buffer display args)
(apply 'process-file program tmpfile buffer display args)
Could you let me know if that alteration is necessary, or whether it's
just that I haven't yet properly understood the information you gave me.
Thanks again,
Dan
>
>> Dan
>
> Best regards, Michael.