From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: William Stevenson Newsgroups: gmane.emacs.help Subject: Re: Pipe bash file contents to shell Date: Fri, 01 Jul 2011 03:15:59 +0100 Message-ID: References: <31968924.post@talk.nabble.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1309486694 4403 80.91.229.12 (1 Jul 2011 02:18:14 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 1 Jul 2011 02:18:14 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Jul 01 04:18:11 2011 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QcTJ4-0002dc-QL for geh-help-gnu-emacs@m.gmane.org; Fri, 01 Jul 2011 04:18:10 +0200 Original-Received: from localhost ([::1]:34856 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QcTJ3-0007M8-IX for geh-help-gnu-emacs@m.gmane.org; Thu, 30 Jun 2011 22:18:09 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:37950) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QcTHK-0007Ka-ME for help-gnu-emacs@gnu.org; Thu, 30 Jun 2011 22:16:24 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QcTHF-0007v3-7D for help-gnu-emacs@gnu.org; Thu, 30 Jun 2011 22:16:19 -0400 Original-Received: from lo.gmane.org ([80.91.229.12]:47286) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QcTHE-0007se-8W for help-gnu-emacs@gnu.org; Thu, 30 Jun 2011 22:16:16 -0400 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1QcTHC-0002CL-BY for help-gnu-emacs@gnu.org; Fri, 01 Jul 2011 04:16:14 +0200 Original-Received: from cpc7-belf9-2-0-cust50.2-1.cable.virginmedia.com ([81.99.65.51]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 01 Jul 2011 04:16:14 +0200 Original-Received: from yhvh2000 by cpc7-belf9-2-0-cust50.2-1.cable.virginmedia.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 01 Jul 2011 04:16:14 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 29 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: cpc7-belf9-2-0-cust50.2-1.cable.virginmedia.com User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAFVBMVEVMEhl7LzAuAwhMHiLd wLuFQkNaJilixb28AAACHElEQVQ4jV3Ty3biMAwGYMWZskYw8TqjTLtm4pInSPb1OTHrhBS//yPM b9lQWu/Qd6xLLGgcxymEcInlbEPsu3kcCTACwhfwVZ5Br2zOubM99ref4ESkktifvyCnyVD1rwWm cHFuwIUeYOXt8BrKjdWLuJwJ0NmXEBQ8ASjDbi+y3gpcKBiilWO0jGZlF11U+DANc2otWDKip0ow fZhzCA3ivoSl/0ep2eOpjUSB+QGDpSnMl+2EQOUZp0CMFMIYXQL2DVe813i3/wTMmzuJ/AkcPFFq Cj/inMFI2zCqX4UOqfSwzjRNwSLTLuwBi7QJOtfM6GpCBnnzFeBo3g5aZP2d5vAblVR2qQ5SWSPV rwKE2YOCEUZr1Yum4obpxafJ92wqJl7WJUH6GpxhqZiJdsw3yksSfJNvrGwJEvsMHgUUIhLV9Ymc I92EkFpKxeOCWDrnAqg/g4/15sqhcZonlZk5Xtt7fMANBXxClDRSD/GRKoNP7aNq/AnplaKjQfe0 z8XLDcBWxwLvKP4Euo+Arnu/d5XAuiGlB/cJxjmUGtbF+xid7i5eVzOxrrxzWwFkGjNwpPt8z5A+ K9ZIhz9rqkkhxfW9Ee/fH8ALtWRao/E7YPiA9DtKJ9eYH/9BrfwFj/+gjrE84p8Fcrd2MYJ3RVzG O0yaCqvd1uSwut/Axg3vRGKk//sN8FlNW59a/HW/gU2AsX+CB6C4oHaG/7449jZiFODnAAAAAElF TkSuQmCC Cancel-Lock: sha1:08v1gaFFkscc+LNDTuSyPlffj9U= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 80.91.229.12 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:81465 Archived-At: linuxfever writes: > I managed to create a part of the lisp function as follows: > > (defun pipe-region-to-shell () > (interactive) > (process-send-string "shell" (format "cd %s\n" (file-name-directory > (buffer-file-name)))) > (process-send-region "shell" (region-beginning) (region-end))) > > The first line makes the shell go to the directory where the bash script is, > and the second one sends the highlighted region to the shell. And all these > happen in the background as I need. The only problem is that the function > assumes that a buffer named "shell" exists. You want get-buffer-create I think get-buffer-create is a built-in function in `C source code'. (get-buffer-create BUFFER-OR-NAME) Return the buffer specified by BUFFER-OR-NAME, creating a new one if needed. If BUFFER-OR-NAME is a string and a live buffer with that name exists, return that buffer. If no such buffer exists, create a new buffer with that name and return it. If BUFFER-OR-NAME starts with a space, the new buffer does not keep undo information. If BUFFER-OR-NAME is a buffer instead of a string, return it as given, even if it is dead. The return value is never nil.