* Pipe bash file contents to shell
@ 2011-06-30 14:33 linuxfever
2011-06-30 17:49 ` Andreas Röhler
2011-06-30 18:01 ` Andreas Röhler
0 siblings, 2 replies; 7+ messages in thread
From: linuxfever @ 2011-06-30 14:33 UTC (permalink / raw)
To: Help-gnu-emacs
Hello all,
I was wondering whether there is a way to pass contents of a bash script
file into a shell buffer in Emacs (23.2). For example, if my bash file
contains a single line "ls -al", I would like to highlight that line, and by
pressing a keybind, have the command executed and its output shown in the
shell buffer.
Is it at all possible? Thanks for any suggestions!
--
View this message in context: http://old.nabble.com/Pipe-bash-file-contents-to-shell-tp31963679p31963679.html
Sent from the Emacs - Help mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Pipe bash file contents to shell
2011-06-30 14:33 Pipe bash file contents to shell linuxfever
@ 2011-06-30 17:49 ` Andreas Röhler
2011-06-30 18:01 ` Andreas Röhler
1 sibling, 0 replies; 7+ messages in thread
From: Andreas Röhler @ 2011-06-30 17:49 UTC (permalink / raw)
To: help-gnu-emacs
Am 30.06.2011 16:33, schrieb linuxfever:
>
> Hello all,
>
> I was wondering whether there is a way to pass contents of a bash script
> file into a shell buffer in Emacs (23.2). For example, if my bash file
> contains a single line "ls -al", I would like to highlight that line, and by
> pressing a keybind, have the command executed and its output shown in the
> shell buffer.
>
> Is it at all possible? Thanks for any suggestions!
>
>
shell-command-on-region
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Pipe bash file contents to shell
2011-06-30 14:33 Pipe bash file contents to shell linuxfever
2011-06-30 17:49 ` Andreas Röhler
@ 2011-06-30 18:01 ` Andreas Röhler
2011-06-30 20:48 ` linuxfever
1 sibling, 1 reply; 7+ messages in thread
From: Andreas Röhler @ 2011-06-30 18:01 UTC (permalink / raw)
To: help-gnu-emacs
Am 30.06.2011 16:33, schrieb linuxfever:
>
> Hello all,
>
> I was wondering whether there is a way to pass contents of a bash script
> file into a shell buffer in Emacs (23.2). For example, if my bash file
> contains a single line "ls -al", I would like to highlight that line, and by
> pressing a keybind, have the command executed and its output shown in the
> shell buffer.
>
> Is it at all possible? Thanks for any suggestions!
>
>
eh, correcting my previous messages.
"shell-command-on-region" is here not the right starting point.
So let me consider your question again:
you have a bash-script. To which directory would `ls -al' point?
How it's written?
Basically it's possible.
However, maybe to get the results you want, Emacs provides better ways,
for example via dired.
Andreas
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Pipe bash file contents to shell
2011-06-30 18:01 ` Andreas Röhler
@ 2011-06-30 20:48 ` linuxfever
0 siblings, 0 replies; 7+ messages in thread
From: linuxfever @ 2011-06-30 20:48 UTC (permalink / raw)
To: Help-gnu-emacs
So, the idea is that my script will contain lines of this form:
./c_code args
where c_code is a C program in the same directory where my bash file is.
Therefore, the idea is the following:
1) Highlight line
2) open shell (if one does not exist already) and cd to the directory where
the bash file is
3) send the line to the shell
Ideally, all this would be happening in the background; something similar to
what ESS does for the R language.
Thanks for your help!
Andreas Röhler wrote:
>
> Am 30.06.2011 16:33, schrieb linuxfever:
>>
>> Hello all,
>>
>> I was wondering whether there is a way to pass contents of a bash script
>> file into a shell buffer in Emacs (23.2). For example, if my bash file
>> contains a single line "ls -al", I would like to highlight that line, and
>> by
>> pressing a keybind, have the command executed and its output shown in the
>> shell buffer.
>>
>> Is it at all possible? Thanks for any suggestions!
>>
>>
>
> eh, correcting my previous messages.
> "shell-command-on-region" is here not the right starting point.
>
> So let me consider your question again:
>
> you have a bash-script. To which directory would `ls -al' point?
> How it's written?
>
> Basically it's possible.
> However, maybe to get the results you want, Emacs provides better ways,
> for example via dired.
>
> Andreas
>
>
>
--
View this message in context: http://old.nabble.com/Pipe-bash-file-contents-to-shell-tp31963679p31968005.html
Sent from the Emacs - Help mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Pipe bash file contents to shell
@ 2011-06-30 21:52 linuxfever
2011-07-01 2:15 ` William Stevenson
0 siblings, 1 reply; 7+ messages in thread
From: linuxfever @ 2011-06-30 21:52 UTC (permalink / raw)
To: Help-gnu-emacs
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.
--
View this message in context: http://old.nabble.com/Pipe-bash-file-contents-to-shell-tp31963679p31968924.html
Sent from the Emacs - Help mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Pipe bash file contents to shell
2011-06-30 21:52 linuxfever
@ 2011-07-01 2:15 ` William Stevenson
0 siblings, 0 replies; 7+ messages in thread
From: William Stevenson @ 2011-07-01 2:15 UTC (permalink / raw)
To: help-gnu-emacs
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.
^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <mailman.764.1309451932.785.help-gnu-emacs@gnu.org>]
end of thread, other threads:[~2011-07-01 17:23 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-30 14:33 Pipe bash file contents to shell linuxfever
2011-06-30 17:49 ` Andreas Röhler
2011-06-30 18:01 ` Andreas Röhler
2011-06-30 20:48 ` linuxfever
-- strict thread matches above, loose matches on Subject: below --
2011-06-30 21:52 linuxfever
2011-07-01 2:15 ` William Stevenson
[not found] <mailman.764.1309451932.785.help-gnu-emacs@gnu.org>
2011-07-01 17:23 ` rusi
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).