Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!samsung!zaphod.mps.ohio-state.edu!mips!apple!oliveb!orc!mipos3!iwarp.intel.com!news From: merlyn@iwarp.intel.com (Randal Schwartz) Newsgroups: gnu.emacs Subject: Re: resuming suspended Emacs Message-ID: <1990Feb5.211815.7236@iwarp.intel.com> Date: 5 Feb 90 21:18:15 GMT References: <9002051421.AA06553@life.ai.mit.edu> Sender: news@iwarp.intel.com Reply-To: merlyn@iwarp.intel.com (Randal Schwartz) Distribution: gnu Organization: Stonehenge; netaccess via Intel, Beaverton, Oregon, USA Lines: 104 In-Reply-To: jbw@bucsf.bu.edu (Joe Wells) In article , jbw@bucsf (Joe Wells) writes: | Well, I imagine most people just use "fg", but you may want fancier | functionality. I'm including a package I wrote to handle this. The idea | is that the first time you start emacs, command line arguments are handled | normally. Then, you suspend your emacs job. When you want to edit | something else, you type "emacs filename" as usual, but instead of | starting a new emacs job, the old job is resumed instead, and the command | line arguments are placed in a file where the old emacs job looks for | them. [code deleted] But, why even do *any* of this? I *never* suspend my Emacs... I just fire off all the shells I want from inside. My main launching is done with my "background-shell-command", attached herewith. The original idea was stolen from monkey, but I reimplemented a bunch. That way, I get a "hardcopy" of the input and output of a shell operation, and can cut and paste, as if I had a smart terminal with windows. Okay, so I can't run 'vi' under emacs... so what! :-) Just another Emacs 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!"=/ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; CODE FOLLOWS ;;; ;;; 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)))))