Xref: utzoo comp.emacs:8911 gnu.emacs:3550 Path: utzoo!attcan!uunet!tut.cis.ohio-state.edu!ucbvax!iwarp.intel.com!news From: merlyn@iwarp.intel.com (Randal Schwartz) Newsgroups: comp.emacs,gnu.emacs Subject: Re: Shell mode with more than one shell? Message-ID: <1990Aug20.160920.25393@iwarp.intel.com> Date: 20 Aug 90 16:09:20 GMT References: <1990Aug20.075002.12385@solar.card.inpu.oz.au> Sender: news@iwarp.intel.com Reply-To: merlyn@iwarp.intel.com (Randal Schwartz) Organization: Stonehenge; netaccess via Intel, Beaverton, Oregon, USA Lines: 102 In-Reply-To: brett@solar.card.inpu.oz.au (Brett Sealey) 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!"=/