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

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!"=/

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]       /  |/  <_!.|  | |  | \_/ \_/ | \|