all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* shell-command-on-region with TRAMP - local binary
@ 2009-01-20 15:21 Terrence Brannon
  2009-01-20 16:33 ` Terrence Brannon
  2009-01-20 17:56 ` Ian Eure
  0 siblings, 2 replies; 4+ messages in thread
From: Terrence Brannon @ 2009-01-20 15:21 UTC (permalink / raw)
  To: help-gnu-emacs

i want to run HTML Tidy using a binary on my local machine ... the
problem is the buffer I want to run it on is being edited via TRAMP
ssh on a remote machine. So the shell-command-on-region uses ssh to
run the command.

How can I run shell-command-on-region on a remote buffer using a local
binary?


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

* Re: shell-command-on-region with TRAMP - local binary
  2009-01-20 15:21 shell-command-on-region with TRAMP - local binary Terrence Brannon
@ 2009-01-20 16:33 ` Terrence Brannon
  2009-01-20 17:06   ` Xah Lee
  2009-01-20 17:56 ` Ian Eure
  1 sibling, 1 reply; 4+ messages in thread
From: Terrence Brannon @ 2009-01-20 16:33 UTC (permalink / raw)
  To: help-gnu-emacs

On Jan 20, 10:21 am, Terrence Brannon <metap...@gmail.com> wrote:

>
> How can I run shell-command-on-region on a remote buffer using a local
> binary?

My current solution is to paste the buffer to a local *scratch* buffer
and run the command there and then paste it back...

sounds like a nice elisp job for a hungry hacker ;-)

code welcome!


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

* Re: shell-command-on-region with TRAMP - local binary
  2009-01-20 16:33 ` Terrence Brannon
@ 2009-01-20 17:06   ` Xah Lee
  0 siblings, 0 replies; 4+ messages in thread
From: Xah Lee @ 2009-01-20 17:06 UTC (permalink / raw)
  To: help-gnu-emacs

On Jan 20, 8:33 am, Terrence Brannon <metap...@gmail.com> wrote:
> How can I run shell-command-on-region on a remote buffer using a local
> binary?
>
> My current solution is to paste the buffer to a local *scratch* buffer
> and run the command there and then paste it back...
>
> sounds like a nice elisp job for a hungry hacker ;-)
>
> code welcome!

very easy. Your code will simply do the following:

• grab the current buffer's content.
• create a new buffer (or temp file locally)
• run tidy on it.

string together the following snippets will do

(defun ()
"run tramp on current buffer"
(interactive)
...
)

(setq mybuffer (current-buffer))
(setq meat (buffer-string))  ; possibly (widen) first
(with-temp-buffer ; creates new buffer that will be gone after running
  (insert meat)
  (shell-command-on-region ...)
)

the important part is that when you create a temp buffer, its file
path must be local. i think by default with-temp-buffer will not do...
so you might use something like temp file with a local path instead,
e.g.

(defun new-temp-file ()
  "Open a new temp file in “~/Document/temp/”"
  (interactive)
  (random t)
  (find-file
   (concat "~/Documents/temp/" "tmp_"
           (number-to-string (random 999)))))

or

(switch-to-buffer "some random name") ; creates new buffer

O, you can probably just use with-temp-buffer and set its current dir
path will do. You'll have to do some doc searching on the var name for
the path.

if the above is not clear, the following will help:

(example of using shell-command-on-region)
• Elisp Wrapper For Perl Scripts
  http://xahlee.org/emacs/elisp_perl_wrapper.html

(example code of dealing with current buffer)
• Elisp Lesson: Execute/Compile Current File
  http://xahlee.org/emacs/elisp_run_current_file.html

  Xah
∑ http://xahlee.org/^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: shell-command-on-region with TRAMP - local binary
  2009-01-20 15:21 shell-command-on-region with TRAMP - local binary Terrence Brannon
  2009-01-20 16:33 ` Terrence Brannon
@ 2009-01-20 17:56 ` Ian Eure
  1 sibling, 0 replies; 4+ messages in thread
From: Ian Eure @ 2009-01-20 17:56 UTC (permalink / raw)
  To: Terrence Brannon; +Cc: help-gnu-emacs

On Jan 20, 2009, at 7:21 AM, Terrence Brannon wrote:

> i want to run HTML Tidy using a binary on my local machine ... the
> problem is the buffer I want to run it on is being edited via TRAMP
> ssh on a remote machine. So the shell-command-on-region uses ssh to
> run the command.
>
> How can I run shell-command-on-region on a remote buffer using a local
> binary?

M-: (let ((default-directory "/")) (call-interactively 'shell-command- 
on-region)) RET

If you never want to use shell-command-on-region with remote  
processes, you can define around-advice for that function. Otherwise,  
I think you'll need another function that sets default-directory to a  
local path.

  - Ian




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

end of thread, other threads:[~2009-01-20 17:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-20 15:21 shell-command-on-region with TRAMP - local binary Terrence Brannon
2009-01-20 16:33 ` Terrence Brannon
2009-01-20 17:06   ` Xah Lee
2009-01-20 17:56 ` Ian Eure

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.