From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Xah Lee Newsgroups: gmane.emacs.help Subject: Re: shell-command-on-region with TRAMP - local binary Date: Tue, 20 Jan 2009 09:06:40 -0800 (PST) Organization: http://groups.google.com Message-ID: References: <847860d8-f647-4633-bf43-8c98a4005761@w1g2000prm.googlegroups.com> <42130e7a-4d3a-416e-98fa-483306e4425b@q30g2000prq.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1232572441 6623 80.91.229.12 (21 Jan 2009 21:14:01 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 21 Jan 2009 21:14:01 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Jan 21 22:15:13 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1LPkPp-0008WO-C8 for geh-help-gnu-emacs@m.gmane.org; Wed, 21 Jan 2009 22:15:13 +0100 Original-Received: from localhost ([127.0.0.1]:42371 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LPkOX-0002i0-Ui for geh-help-gnu-emacs@m.gmane.org; Wed, 21 Jan 2009 16:13:53 -0500 Original-Path: news.stanford.edu!newsfeed.stanford.edu!postnews.google.com!r15g2000prd.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 67 Original-NNTP-Posting-Host: 24.6.175.142 Original-X-Trace: posting.google.com 1232471231 4307 127.0.0.1 (20 Jan 2009 17:07:11 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Tue, 20 Jan 2009 17:07:11 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: r15g2000prd.googlegroups.com; posting-host=24.6.175.142; posting-account=bRPKjQoAAACxZsR8_VPXCX27T2YcsyMA User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_4_11; en) AppleWebKit/525.27.1 (KHTML, like Gecko) Version/3.2.1 Safari/525.27.1, gzip(gfe), gzip(gfe) Original-Xref: news.stanford.edu gnu.emacs.help:166182 X-Mailman-Approved-At: Wed, 21 Jan 2009 16:13:18 -0500 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:61538 Archived-At: On Jan 20, 8:33 am, Terrence Brannon 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: =E2=80=A2 grab the current buffer's content. =E2=80=A2 create a new buffer (or temp file locally) =E2=80=A2 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 =E2=80=9C~/Document/temp/=E2=80=9D" (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) =E2=80=A2 Elisp Wrapper For Perl Scripts http://xahlee.org/emacs/elisp_perl_wrapper.html (example code of dealing with current buffer) =E2=80=A2 Elisp Lesson: Execute/Compile Current File http://xahlee.org/emacs/elisp_run_current_file.html Xah =E2=88=91 http://xahlee.org/ =E2=98=84