all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Xah Lee <xahlee@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: shell-command-on-region with TRAMP - local binary
Date: Tue, 20 Jan 2009 09:06:40 -0800 (PST)	[thread overview]
Message-ID: <ab5e9abb-5e4f-46ff-9505-342c2ddea40d@r15g2000prd.googlegroups.com> (raw)
In-Reply-To: 42130e7a-4d3a-416e-98fa-483306e4425b@q30g2000prq.googlegroups.com

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/

  reply	other threads:[~2009-01-20 17:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2009-01-20 17:56 ` Ian Eure

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ab5e9abb-5e4f-46ff-9505-342c2ddea40d@r15g2000prd.googlegroups.com \
    --to=xahlee@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.