From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: jpkotta Newsgroups: gmane.emacs.help Subject: Re: Inserting output from a program into a buffer Date: Mon, 22 Feb 2010 15:06:15 -0800 (PST) Organization: http://groups.google.com Message-ID: References: <87zl324774.fsf@lion.rapttech.com.au> <87k4u66nhh.fsf@galatea.lan.informatimago.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1266882121 20500 80.91.229.12 (22 Feb 2010 23:42:01 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 22 Feb 2010 23:42: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 Tue Feb 23 00:41:56 2010 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.69) (envelope-from ) id 1NjhuU-0007mE-G4 for geh-help-gnu-emacs@m.gmane.org; Tue, 23 Feb 2010 00:41:54 +0100 Original-Received: from localhost ([127.0.0.1]:47216 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NjhuU-00047U-0z for geh-help-gnu-emacs@m.gmane.org; Mon, 22 Feb 2010 18:41:54 -0500 Original-Path: news.stanford.edu!usenet.stanford.edu!postnews.google.com!m37g2000yqf.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 35 Original-NNTP-Posting-Host: 64.122.85.37 Original-X-Trace: posting.google.com 1266879975 29304 127.0.0.1 (22 Feb 2010 23:06:15 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Mon, 22 Feb 2010 23:06:15 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: m37g2000yqf.googlegroups.com; posting-host=64.122.85.37; posting-account=EwI0QQoAAADdqmqX_mVfawBNtwyks2YE User-Agent: G2/1.0 X-HTTP-UserAgent: Opera/9.80 (X11; Linux x86_64; U; en) Presto/2.2.15 Version/10.10,gzip(gfe),gzip(gfe) Original-Xref: news.stanford.edu gnu.emacs.help:177002 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:72040 Archived-At: On Feb 21, 10:45=A0pm, Tim Johnson wrote: > On 2010-02-22, Pascal J. Bourguignon wrote: > <..>> You could get a string without attribute using the function > > buffer-substring-no-properties instead of buffer-substring. > > =A0Oh! Deja vu here... I believe that what I really need is > =A0buffer-substring- to copy the region directly to a > =A0variable. > =A0thanks Pascal > > -- > Tim > t...@johnsons-web.comhttp://www.akwebsoft.com I wrote this a couple of weeks ago, and just extended it to work when the region is active. ,---- | ;; see also C-u M-| | (defun insert-from-shell-current-line () | "Run the current line as a shell command, and put the output | immediately after it. If the region is active, use for the | command." | (interactive "*") | (let ((start (line-beginning-position)) | (stop (line-end-position))) | (when (region-active-p) | (setq start (region-beginning)) | (setq stop (region-end))) | (goto-char stop) | (insert "\n") | (insert (shell-command-to-string | (buffer-substring start stop))))) `----