[comp.emacs] Shell mode with more than one shell?

brett@solar.card.inpu.oz.au (Brett Sealey) (08/20/90)

Is there a way to have more than one inferior shell process running under
emacs?

What I want is a "nice" way of having a few interactive shells running at
the same time in different buffers. e.g. *shell-1* *shell-2* etc...

Why shell mode doesn't let you do this already is a mystery to me.

Anyway, thanks in advance.


-- 
______________________________________________________________________________
  __   __   ___ ____ ____
 /__) /__) /_    /    /				brett@solar.card.inpu.oz.au
/__) / \  /__   /    /					       Brett Sealey

brett@solar.card.inpu.oz.au (Brett Sealey) (08/20/90)

I asked about how to get more than one inferior shell process under emacs.

My thanks to Carl Witty for his prompt reply.

> If you rename the shell buffer yourself, the next time you type M-x
> shell you get a "new" shell.
> 
> (i.e. M-x rename-buffer RET *shell-2* RET)

This was just what the doctor ordered.

Thanks.
-- 
______________________________________________________________________________
  __   __   ___ ____ ____
 /__) /__) /_    /    /				brett@solar.card.inpu.oz.au
/__) / \  /__   /    /					       Brett Sealey

merlyn@iwarp.intel.com (Randal Schwartz) (08/20/90)

In article <1990Aug20.075002.12385@solar.card.inpu.oz.au>, brett@solar (Brett Sealey) writes:
| I asked about how to get more than one inferior shell process under emacs.
| 
| My thanks to Carl Witty for his prompt reply.
| 
| > If you rename the shell buffer yourself, the next time you type M-x
| > shell you get a "new" shell.
| > 
| > (i.e. M-x rename-buffer RET *shell-2* RET)
| 
| This was just what the doctor ordered.
| 
| Thanks.

I never use shell-mode, preferring it instead to this package that I
shamelessly stole the idea from someone whose name escapes me now.

For an interactive shell, invoke a command of "sh".  But typically,
it's easier to invoke the command you want directly.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; clip here	
;;; original version by merlyn
;;; LastEditDate="Thu Mar 16 13:16:13 1989"

(defun background-shell (command &optional show)
  "Create a background shell on COMMAND.
If optional SHOW is non-nil (prefix argument if interactive), force
the buffer for COMMAND to be visible in a window."
  (interactive "s& \nP")
  (let ((process (start-process "&shell"
				(generate-new-buffer "&shell")
				shell-file-name
				"-c"
				command)))
    (set-marker (process-mark process) 1 (process-buffer process))
    (set-process-filter
     process
     (function
      (lambda (process text)
	(cond ((buffer-name (process-buffer process))
	       (save-excursion
		 (set-buffer (process-buffer process))
		 (goto-char (process-mark process))
		 (let ((bmp (buffer-modified-p)))
		   (insert-before-markers text)
		   (set-buffer-modified-p bmp))))))))
    (set-process-sentinel
     process
     (function
      (lambda (process reason)
	(setq reason (substring reason 0 -1)) ; kill \n at end
	(let ((status (process-status process)))
	  (cond ((memq status '(stop signal exit))
		 (cond ((buffer-name (process-buffer process))
			(save-excursion
			  (set-buffer (process-buffer process))
			  (goto-char (point-max)) ; should be process-mark?
			  (let ((bmp (buffer-modified-p)))
			    (insert-before-markers
			     "\n\n*** "
			     (current-time-string) ": " reason
			     " ***\n\n")
			    (set-buffer-modified-p bmp))
			  (let ((cw (get-buffer-window (current-buffer))))
			    (if cw
				(set-window-start
				 cw
				 (save-excursion
				   (forward-line (- 2 (window-height cw)))
				   (point))
				 t)))
			    
			  (cond ((memq status '(signal exit))
				 (setq mode-line-process nil))))))
		 (message "[process %s in buffer %s %s]"
			  (process-name process)
			  (buffer-name (process-buffer process))
			  reason
			  (ding t))))))))
    (save-excursion
      (set-buffer (process-buffer process))
      (require 'shell)
      (shell-mode)
      (insert-before-markers "*** Input ***\n" command "\n*** Output ***\n")
      (setq mode-line-process '(": %s"))
      (set-buffer-modified-p nil)
      (if show
	  (let ((sw (selected-window)))
	    (select-window (display-buffer (current-buffer) t))
	    (select-window sw))))
    (message "[started process %s in buffer %s]"
	     (process-name process)
	     (buffer-name (process-buffer process)))))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; clip here

Just another elisp hacker,
-- 
/=Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ==========\
| on contract to Intel's iWarp project, Beaverton, Oregon, USA, Sol III      |
| merlyn@iwarp.intel.com ...!any-MX-mailer-like-uunet!iwarp.intel.com!merlyn |
\=Cute Quote: "Welcome to Portland, Oregon, home of the California Raisins!"=/

de5@STC06.CTD.ORNL.GOV (SILL D E) (08/20/90)

In article <1990Aug20.055736.12250@solar.card.inpu.oz.au> brett@solar.card.inpu.oz.au writes:
>
>What I want is a "nice" way of having a few interactive shells running at
>the same time in different buffers. e.g. *shell-1* *shell-2* etc...

You can manually rename the *Shell* buffer to something else, as has
already been pointed out, or you might prefer one of the following
packages:

multishell        88-10-17
     Dale Worley, <compass!worley>
     Multiple *Shell* buffers.
new-shell         
     Robert Wells, <rwells@bbn.com>
     tut.cis.ohio-state.edu:pub/gnu/emacs/elisp-archive/as-is/new-shell.el.Z
     Named shell buffers; better send-input.

-- 
Dave Sill (de5@ornl.gov)		These are my opinions.
Martin Marietta Energy Systems
Workstation Support

hollen@megatek.UUCP (Dion Hollenbeck) (08/21/90)

From article <1990Aug20.055736.12250@solar.card.inpu.oz.au>, by brett@solar.card.inpu.oz.au (Brett Sealey):
> Is there a way to have more than one inferior shell process running under
> emacs?
> 
> What I want is a "nice" way of having a few interactive shells running at
> the same time in different buffers. e.g. *shell-1* *shell-2* etc...
> 
> Why shell mode doesn't let you do this already is a mystery to me.
> 
Here is what I use.  However, all my shell's names are prefaced with
'-' because I would have to use the shift key to produce * and I like
as few keystrokes as possible.  The code also includes an example
to rlogin into another machine in one of the shells in case you
need to compile on more than one platform at a time.


;;  define function to start up another shell in a buffer
(defun beginshell () 
  (interactive)
  (shell)
)



;;
;;    set up shell processes in lots of windown
;;

;  first shell is an rlogin to another host
(beginshell)
(rename-buffer "-icp")
(insert "rsh akbar")
(shell-send-input)

;  the rest of these are just 4 shells on current machine
(beginshell)
(rename-buffer "-dshell")
(beginshell)
(rename-buffer "-cshell")
(beginshell)
(rename-buffer "-bshell")
(beginshell)
(rename-buffer "-ashell")

;  you are left "logged in" to -ashell when this completes

-- 
	Dion Hollenbeck             (619) 455-5590 x2814
	Megatek Corporation, 9645 Scranton Road, San Diego, CA  92121

        uunet!megatek!hollen       or  hollen@megatek.uucp

nyoo@priam.usc.edu (Namhoon Yoo) (08/29/90)

Dear Netters,

When we "rlogin" in the shell-mode of emacs, is there any way to open
a screen editor (vi or emacs) in the remote machine?

The question is what is the correct terminal type which emacs' shell
provides and usual screen editor supports for.

Your advice will be greatly appreciated.
Thanks.

Regards                                /|  / _
Namhoon Yoo      (213)743-2459	      / | / '_| |\/| |__| /~\ /~\ |\ |
[Internet: nyoo@priam.usc.edu]       /  |/  <_!.|  | |  | \_/ \_/ | \|


-- 

Regards                                /|  / _
Namhoon Yoo      (213)743-2459	      / | / '_| |\/| |__| /~\ /~\ |\ |
[Internet: nyoo@priam.usc.edu]       /  |/  <_!.|  | |  | \_/ \_/ | \|