Thread View: gnu.emacs.sources
1 messages
1 total messages
Started by John Interrante
Wed, 27 Jan 1993 05:37
patch to make background behave like shell-command
Author: John Interrante
Date: Wed, 27 Jan 1993 05:37
Date: Wed, 27 Jan 1993 05:37
100 lines
4608 bytes
4608 bytes
I felt that background should behave like shell-command; that is, it
should display the process buffer if and only if the background job
produces any output. Here're my changes to background.el. I deleted
the user variables background-show and background-select and I added a
process filter to display the buffer the first time the background job
produces any output. I have been using these changes for one week
before posting them and they have not given me any problems.
John Interrante / interran@uluru.stanford.edu
Computer Systems Laboratory, Stanford University
*** comint-2.03/background.el.save Sat Aug 24 13:36:36 1991
--- comint-2.03/background.el Wed Jan 20 10:36:23 1993
***************
*** 17,38 ****
;; - Fixed up the sentinel to protect match-data around invocations.
;; Also slightly rearranged the cd match code for similar reasons.
;; Olin 7/16/91
(provide 'background)
(require 'comint)
- ;; user variables
- (defvar background-show t
- "*If non-nil, background jobs' buffers are shown when they're started.")
- (defvar background-select nil
- "*If non-nil, background jobs' buffers are selected when they're started.")
-
(defun background (command)
! "Run COMMAND in the background like csh.
A message is displayed when the job starts and finishes. The buffer is in
comint mode, so you can send input and signals to the job. The process object
! is returned if anyone cares. See also comint-mode and the variables
! background-show and background-select."
(interactive "s%% ")
(let ((job-number 1)
(job-name "%1")
--- 17,34 ----
;; - Fixed up the sentinel to protect match-data around invocations.
;; Also slightly rearranged the cd match code for similar reasons.
;; Olin 7/16/91
+ ;; - Made background behave like shell-command in that it displays the
+ ;; process buffer if and only if the background job produces any output.
+ ;; J. Interrante 1/18/93
(provide 'background)
(require 'comint)
(defun background (command)
! "Run COMMAND in the background like csh; display output, if any.
A message is displayed when the job starts and finishes. The buffer is in
comint mode, so you can send input and signals to the job. The process object
! is returned if anyone cares. See also comint-mode."
(interactive "s%% ")
(let ((job-number 1)
(job-name "%1")
***************
*** 39,47 ****
(dir default-directory))
(while (process-status job-name)
(setq job-name (concat "%" (setq job-number (1+ job-number)))))
! (if background-select (pop-to-buffer job-name)
! (if background-show (with-output-to-temp-buffer job-name)) ; cute
! (set-buffer (get-buffer-create job-name)))
(erase-buffer)
(setq default-directory dir) ; Do this first, in case cd is relative path.
--- 35,41 ----
(dir default-directory))
(while (process-status job-name)
(setq job-name (concat "%" (setq job-number (1+ job-number)))))
! (set-buffer (get-buffer-create job-name))
(erase-buffer)
(setq default-directory dir) ; Do this first, in case cd is relative path.
***************
*** 60,65 ****
--- 54,60 ----
(comint-mode)
;; COND because the proc may have died before the G-B-P is called.
(cond (proc (set-process-sentinel proc 'background-sentinel)
+ (set-process-filter proc 'background-filter)
(message "[%d] %d" job-number (process-id proc))))
(setq mode-name "Background")
proc)))
***************
*** 90,92 ****
--- 85,96 ----
(if at-end (goto-char (point-max))))
(set-buffer-modified-p nil)))))
(store-match-data ms))))
+
+ (defun background-filter (process output)
+ "Called to make buffer visible when a background job produces output."
+ (save-excursion
+ (display-buffer (set-buffer (process-buffer process)))
+ (goto-char (point-max))
+ (insert output)
+ (set-marker (process-mark process) (point))
+ (set-process-filter process nil)))
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads