Mercurial > emacs
comparison lisp/eshell/esh-proc.el @ 79345:5339903c5abe
Johan Bockg? <bojohan at gnu.org>
(eshell-insertion-filter, eshell-sentinel): Use `with-current-buffer'.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Wed, 07 Nov 2007 03:33:00 +0000 |
parents | a1e8300d3c55 |
children | 48c4bb2b7d11 d8ed6bf7f010 880960b70474 |
comparison
equal
deleted
inserted
replaced
79344:c0cc9997f433 | 79345:5339903c5abe |
---|---|
333 (defun eshell-insertion-filter (proc string) | 333 (defun eshell-insertion-filter (proc string) |
334 "Insert a string into the eshell buffer, or a process/file/buffer. | 334 "Insert a string into the eshell buffer, or a process/file/buffer. |
335 PROC is the process for which we're inserting output. STRING is the | 335 PROC is the process for which we're inserting output. STRING is the |
336 output." | 336 output." |
337 (when (buffer-live-p (process-buffer proc)) | 337 (when (buffer-live-p (process-buffer proc)) |
338 (set-buffer (process-buffer proc)) | 338 (with-current-buffer (process-buffer proc) |
339 (let ((entry (assq proc eshell-process-list))) | 339 (let ((entry (assq proc eshell-process-list))) |
340 (when entry | 340 (when entry |
341 (setcar (nthcdr 3 entry) | 341 (setcar (nthcdr 3 entry) |
342 (concat (nth 3 entry) string)) | 342 (concat (nth 3 entry) string)) |
343 (unless (nth 4 entry) ; already being handled? | 343 (unless (nth 4 entry) ; already being handled? |
344 (while (nth 3 entry) | 344 (while (nth 3 entry) |
345 (let ((data (nth 3 entry))) | 345 (let ((data (nth 3 entry))) |
346 (setcar (nthcdr 3 entry) nil) | 346 (setcar (nthcdr 3 entry) nil) |
347 (setcar (nthcdr 4 entry) t) | 347 (setcar (nthcdr 4 entry) t) |
348 (eshell-output-object data nil (cadr entry)) | 348 (eshell-output-object data nil (cadr entry)) |
349 (setcar (nthcdr 4 entry) nil)))))))) | 349 (setcar (nthcdr 4 entry) nil))))))))) |
350 | 350 |
351 (defun eshell-sentinel (proc string) | 351 (defun eshell-sentinel (proc string) |
352 "Generic sentinel for command processes. Reports only signals. | 352 "Generic sentinel for command processes. Reports only signals. |
353 PROC is the process that's exiting. STRING is the exit message." | 353 PROC is the process that's exiting. STRING is the exit message." |
354 (when (buffer-live-p (process-buffer proc)) | 354 (when (buffer-live-p (process-buffer proc)) |
355 (set-buffer (process-buffer proc)) | 355 (with-current-buffer (process-buffer proc) |
356 (unwind-protect | 356 (unwind-protect |
357 (let* ((entry (assq proc eshell-process-list))) | 357 (let* ((entry (assq proc eshell-process-list))) |
358 ; (if (not entry) | 358 ; (if (not entry) |
359 ; (error "Sentinel called for unowned process `%s'" | 359 ; (error "Sentinel called for unowned process `%s'" |
360 ; (process-name proc)) | 360 ; (process-name proc)) |
361 (when entry | 361 (when entry |
362 (unwind-protect | 362 (unwind-protect |
363 (progn | 363 (progn |
364 (unless (string= string "run") | 364 (unless (string= string "run") |
365 (unless (string-match "^\\(finished\\|exited\\)" string) | 365 (unless (string-match "^\\(finished\\|exited\\)" string) |
366 (eshell-insertion-filter proc string)) | 366 (eshell-insertion-filter proc string)) |
367 (eshell-close-handles (process-exit-status proc) 'nil | 367 (eshell-close-handles (process-exit-status proc) 'nil |
368 (cadr entry)))) | 368 (cadr entry)))) |
369 (eshell-remove-process-entry entry)))) | 369 (eshell-remove-process-entry entry)))) |
370 (run-hook-with-args 'eshell-kill-hook proc string)))) | 370 (run-hook-with-args 'eshell-kill-hook proc string))))) |
371 | 371 |
372 (defun eshell-process-interact (func &optional all query) | 372 (defun eshell-process-interact (func &optional all query) |
373 "Interact with a process, using PROMPT if more than one, via FUNC. | 373 "Interact with a process, using PROMPT if more than one, via FUNC. |
374 If ALL is non-nil, background processes will be interacted with as well. | 374 If ALL is non-nil, background processes will be interacted with as well. |
375 If QUERY is non-nil, query the user with QUERY before calling FUNC." | 375 If QUERY is non-nil, query the user with QUERY before calling FUNC." |