home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / gnu / emacs / sources / 977 < prev    next >
Encoding:
Text File  |  1993-01-28  |  4.4 KB  |  111 lines

  1. Newsgroups: gnu.emacs.sources
  2. Path: sparky!uunet!UB.com!pacbell.com!decwrl!elroy.jpl.nasa.gov!sdd.hp.com!saimiri.primate.wisc.edu!ames!agate!stanford.edu!nntp.Stanford.EDU!nntp!interran
  3. From: interran@uluru.Stanford.EDU (John Interrante)
  4. Subject: patch to make background behave like shell-command
  5. Message-ID: <INTERRAN.93Jan26223729@uluru.Stanford.EDU>
  6. Sender: news@leland.Stanford.EDU (Mr News)
  7. Organization: Stanford University
  8. Date: 27 Jan 1993 05:37:29 GMT
  9. Lines: 100
  10.  
  11. I felt that background should behave like shell-command; that is, it
  12. should display the process buffer if and only if the background job
  13. produces any output.  Here're my changes to background.el.  I deleted
  14. the user variables background-show and background-select and I added a
  15. process filter to display the buffer the first time the background job
  16. produces any output.  I have been using these changes for one week
  17. before posting them and they have not given me any problems.
  18.  
  19. John Interrante / interran@uluru.stanford.edu
  20. Computer Systems Laboratory, Stanford University
  21.  
  22. *** comint-2.03/background.el.save    Sat Aug 24 13:36:36 1991
  23. --- comint-2.03/background.el    Wed Jan 20 10:36:23 1993
  24. ***************
  25. *** 17,38 ****
  26.   ;; - Fixed up the sentinel to protect match-data around invocations.
  27.   ;;   Also slightly rearranged the cd match code for similar reasons.
  28.   ;;   Olin 7/16/91
  29.   
  30.   (provide 'background)
  31.   (require 'comint)
  32.   
  33. - ;; user variables
  34. - (defvar background-show t
  35. -   "*If non-nil, background jobs' buffers are shown when they're started.")
  36. - (defvar background-select nil
  37. -   "*If non-nil, background jobs' buffers are selected when they're started.")
  38.   (defun background (command)
  39. !   "Run COMMAND in the background like csh.  
  40.   A message is displayed when the job starts and finishes.  The buffer is in
  41.   comint mode, so you can send input and signals to the job.  The process object
  42. ! is returned if anyone cares.  See also comint-mode and the variables
  43. ! background-show and background-select."
  44.     (interactive "s%% ")
  45.     (let ((job-number 1)
  46.       (job-name "%1")
  47. --- 17,34 ----
  48.   ;; - Fixed up the sentinel to protect match-data around invocations.
  49.   ;;   Also slightly rearranged the cd match code for similar reasons.
  50.   ;;   Olin 7/16/91
  51. + ;; - Made background behave like shell-command in that it displays the
  52. + ;;   process buffer if and only if the background job produces any output.
  53. + ;;   J. Interrante 1/18/93
  54.   
  55.   (provide 'background)
  56.   (require 'comint)
  57.   
  58.   (defun background (command)
  59. !   "Run COMMAND in the background like csh; display output, if any.
  60.   A message is displayed when the job starts and finishes.  The buffer is in
  61.   comint mode, so you can send input and signals to the job.  The process object
  62. ! is returned if anyone cares.  See also comint-mode."
  63.     (interactive "s%% ")
  64.     (let ((job-number 1)
  65.       (job-name "%1")
  66. ***************
  67. *** 39,47 ****
  68.       (dir default-directory))
  69.       (while (process-status job-name)
  70.         (setq job-name (concat "%" (setq job-number (1+ job-number)))))
  71. !     (if background-select (pop-to-buffer job-name)
  72. !       (if background-show (with-output-to-temp-buffer job-name)) ; cute
  73. !       (set-buffer (get-buffer-create job-name)))
  74.       (erase-buffer)
  75.   
  76.       (setq default-directory dir) ; Do this first, in case cd is relative path.
  77. --- 35,41 ----
  78.       (dir default-directory))
  79.       (while (process-status job-name)
  80.         (setq job-name (concat "%" (setq job-number (1+ job-number)))))
  81. !     (set-buffer (get-buffer-create job-name))
  82.       (erase-buffer)
  83.   
  84.       (setq default-directory dir) ; Do this first, in case cd is relative path.
  85. ***************
  86. *** 60,65 ****
  87. --- 54,60 ----
  88.         (comint-mode)
  89.         ;; COND because the proc may have died before the G-B-P is called.
  90.         (cond (proc (set-process-sentinel proc 'background-sentinel)
  91. +           (set-process-filter proc 'background-filter)
  92.             (message "[%d] %d" job-number (process-id proc))))
  93.         (setq mode-name "Background")
  94.         proc)))
  95. ***************
  96. *** 90,92 ****
  97. --- 85,96 ----
  98.                  (if at-end (goto-char (point-max))))
  99.                (set-buffer-modified-p nil)))))
  100.         (store-match-data ms))))
  101. + (defun background-filter (process output)
  102. +   "Called to make buffer visible when a background job produces output."
  103. +   (save-excursion
  104. +     (display-buffer (set-buffer (process-buffer process)))
  105. +     (goto-char (point-max))
  106. +     (insert output)
  107. +     (set-marker (process-mark process) (point))
  108. +     (set-process-filter process nil)))
  109.