* Execute In Multiple Shells?
@ 2009-11-23 23:03 gamename
2009-11-24 0:13 ` Pascal J. Bourguignon
2009-11-24 9:24 ` Peter Dyballa
0 siblings, 2 replies; 6+ messages in thread
From: gamename @ 2009-11-23 23:03 UTC (permalink / raw)
To: help-gnu-emacs
Hi,
How can I send the same command to multiple shell buffers at the same
time? That is, if I have 5 bash shells running, how can I send
"source ./.bash" to all of them at once?
Thanks,
-T
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Execute In Multiple Shells?
2009-11-23 23:03 Execute In Multiple Shells? gamename
@ 2009-11-24 0:13 ` Pascal J. Bourguignon
2009-11-24 19:32 ` Dmitry Dzhus
2009-11-24 9:24 ` Peter Dyballa
1 sibling, 1 reply; 6+ messages in thread
From: Pascal J. Bourguignon @ 2009-11-24 0:13 UTC (permalink / raw)
To: help-gnu-emacs
gamename <tennis@tripitinc.com> writes:
> How can I send the same command to multiple shell buffers at the same
> time? That is, if I have 5 bash shells running, how can I send
> "source ./.bash" to all of them at once?
(require 'cl)
(defvar buffer-name-map nil)
(defvar buffer-list-cache nil)
(defun buffer-named (name)
"
RETURN: the buffer which has as name `name'.
"
(let ((bl (buffer-list)))
(unless (and buffer-list-cache buffer-name-map
(equal buffer-list-cache bl))
(setf buffer-list-cache (copy-seq bl))
(setf buffer-name-map (make-hash-table :test (function equal)))
(dolist (buffer buffer-list-cache)
(let ((name (buffer-name buffer)))
(when name (setf (gethash name buffer-name-map) buffer)))
(let ((name (buffer-file-name buffer)))
(when name (setf (gethash name buffer-name-map) buffer))))))
(or (gethash name buffer-name-map)
(gethash (truename name) buffer-name-map)))
(defun mapshell (command shell-buffers)
(dolist (shell shell-buffers)
(with-current-buffer (etypecase shell
(string (buffer-named shell))
(buffer shell)
(process (process-buffer shell)))
(if (char= (aref "\n" 0) (aref command (1- (length command))))
(comint-send-string (current-buffer) command)
(comint-send-string (current-buffer) (format "%s\n" command))))))
(mapshell "echo hello\n" (list "0shell" "1shell"))
--
__Pascal Bourguignon__
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Execute In Multiple Shells?
2009-11-23 23:03 Execute In Multiple Shells? gamename
2009-11-24 0:13 ` Pascal J. Bourguignon
@ 2009-11-24 9:24 ` Peter Dyballa
1 sibling, 0 replies; 6+ messages in thread
From: Peter Dyballa @ 2009-11-24 9:24 UTC (permalink / raw)
To: gamename; +Cc: help-gnu-emacs
Am 24.11.2009 um 00:03 schrieb gamename:
> How can I send the same command to multiple shell buffers at the same
> time? That is, if I have 5 bash shells running, how can I send
> "source ./.bash" to all of them at once?
The latter can easily be put into ~/.emacs_bash...
--
Greetings
Pete
I love deadlines. I love the whooshing noise they make as they go by.
– Douglas Adams
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Execute In Multiple Shells?
2009-11-24 0:13 ` Pascal J. Bourguignon
@ 2009-11-24 19:32 ` Dmitry Dzhus
2009-11-24 19:56 ` Pascal J. Bourguignon
0 siblings, 1 reply; 6+ messages in thread
From: Dmitry Dzhus @ 2009-11-24 19:32 UTC (permalink / raw)
To: help-gnu-emacs
Pascal J. Bourguignon wrote:
> (defun buffer-named (name)
> "
> RETURN: the buffer which has as name `name'.
> "
> (let ((bl (buffer-list)))
> (unless (and buffer-list-cache buffer-name-map
> (equal buffer-list-cache bl))
> (setf buffer-list-cache (copy-seq bl))
> (setf buffer-name-map (make-hash-table :test (function equal)))
> (dolist (buffer buffer-list-cache)
> (let ((name (buffer-name buffer)))
> (when name (setf (gethash name buffer-name-map) buffer)))
> (let ((name (buffer-file-name buffer)))
> (when name (setf (gethash name buffer-name-map) buffer))))))
> (or (gethash name buffer-name-map)
> (gethash (truename name) buffer-name-map)))
How is this different from `get-buffer`?
--
Happy Hacking.
http://sphinx.net.ru
む
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Execute In Multiple Shells?
2009-11-24 19:32 ` Dmitry Dzhus
@ 2009-11-24 19:56 ` Pascal J. Bourguignon
2010-01-21 16:27 ` gamename
0 siblings, 1 reply; 6+ messages in thread
From: Pascal J. Bourguignon @ 2009-11-24 19:56 UTC (permalink / raw)
To: help-gnu-emacs
Dmitry Dzhus <dima@sphinx.net.ru> writes:
> Pascal J. Bourguignon wrote:
>
>> (defun buffer-named (name)
>> "
>> RETURN: the buffer which has as name `name'.
>> "
>> (let ((bl (buffer-list)))
>> (unless (and buffer-list-cache buffer-name-map
>> (equal buffer-list-cache bl))
>> (setf buffer-list-cache (copy-seq bl))
>> (setf buffer-name-map (make-hash-table :test (function equal)))
>> (dolist (buffer buffer-list-cache)
>> (let ((name (buffer-name buffer)))
>> (when name (setf (gethash name buffer-name-map) buffer)))
>> (let ((name (buffer-file-name buffer)))
>> (when name (setf (gethash name buffer-name-map) buffer))))))
>> (or (gethash name buffer-name-map)
>> (gethash (truename name) buffer-name-map)))
>
> How is this different from `get-buffer`?
It uses truename, which I forgot to adjoin:
(defun truename (filespec)
"
RETURN: The absolute path name corresponding to fielspec.
"
(car (file-expand-wildcards (shell-quote-argument filespec) t)))
--
__Pascal Bourguignon__
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Execute In Multiple Shells?
2009-11-24 19:56 ` Pascal J. Bourguignon
@ 2010-01-21 16:27 ` gamename
0 siblings, 0 replies; 6+ messages in thread
From: gamename @ 2010-01-21 16:27 UTC (permalink / raw)
To: help-gnu-emacs
On Nov 24 2009, 11:56 am, p...@informatimago.com (Pascal J.
Bourguignon) wrote:
> Dmitry Dzhus <d...@sphinx.net.ru> writes:
> > Pascal J. Bourguignon wrote:
>
> >> (defun buffer-named (name)
> >> "
> >> RETURN: the buffer which has as name `name'.
> >> "
> >> (let ((bl (buffer-list)))
> >> (unless (and buffer-list-cache buffer-name-map
> >> (equal buffer-list-cache bl))
> >> (setf buffer-list-cache (copy-seq bl))
> >> (setf buffer-name-map (make-hash-table :test (function equal)))
> >> (dolist (buffer buffer-list-cache)
> >> (let ((name (buffer-name buffer)))
> >> (when name (setf (gethash name buffer-name-map) buffer)))
> >> (let ((name (buffer-file-name buffer)))
> >> (when name (setf (gethash name buffer-name-map) buffer))))))
> >> (or (gethash name buffer-name-map)
> >> (gethash (truename name) buffer-name-map)))
>
> > How is this different from `get-buffer`?
>
> It uses truename, which I forgot to adjoin:
>
> (defun truename (filespec)
> "
> RETURN: The absolute path name corresponding to fielspec.
> "
> (car (file-expand-wildcards (shell-quote-argument filespec) t)))
>
> --
> __Pascal Bourguignon__
Thanks guys!
-T
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-01-21 16:27 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-23 23:03 Execute In Multiple Shells? gamename
2009-11-24 0:13 ` Pascal J. Bourguignon
2009-11-24 19:32 ` Dmitry Dzhus
2009-11-24 19:56 ` Pascal J. Bourguignon
2010-01-21 16:27 ` gamename
2009-11-24 9:24 ` Peter Dyballa
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).