[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Pipe bash file contents to shell
From: |
William Stevenson |
Subject: |
Re: Pipe bash file contents to shell |
Date: |
Fri, 01 Jul 2011 03:15:59 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) |
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.