unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: William Stevenson <yhvh2000@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Pipe bash file contents to shell
Date: Fri, 01 Jul 2011 03:15:59 +0100	[thread overview]
Message-ID: <m3oc1eagps.fsf@gmail.com> (raw)
In-Reply-To: 31968924.post@talk.nabble.com

linuxfever <linuxfever@yahoo.gr> 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.




  reply	other threads:[~2011-07-01  2:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-30 21:52 Pipe bash file contents to shell linuxfever
2011-07-01  2:15 ` William Stevenson [this message]
     [not found] <mailman.764.1309451932.785.help-gnu-emacs@gnu.org>
2011-07-01 17:23 ` rusi
  -- strict thread matches above, loose matches on Subject: below --
2011-06-30 14:33 linuxfever
2011-06-30 17:49 ` Andreas Röhler
2011-06-30 18:01 ` Andreas Röhler
2011-06-30 20:48   ` linuxfever

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=m3oc1eagps.fsf@gmail.com \
    --to=yhvh2000@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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).