diff options
| author | Eli Zaretskii | 1997-02-03 18:02:26 +0000 |
|---|---|---|
| committer | Eli Zaretskii | 1997-02-03 18:02:26 +0000 |
| commit | 0020dbcd12e162f0cc41604716141b68c4396251 (patch) | |
| tree | eaaff3c1bdbe9bb39b9c154d7ef9fdf2ffb47211 | |
| parent | c2604a9b8632d7be52d82d14f9ba43c0c75cc423 (diff) | |
| download | emacs-0020dbcd12e162f0cc41604716141b68c4396251.tar.gz emacs-0020dbcd12e162f0cc41604716141b68c4396251.zip | |
(Man-build-man-command): When async processes aren't
supported, don't redirect stderr via the shell.
(Man-getpage-in-background, Man-bgproc-sentinel): Support for
systems where async processes don't work.
| -rw-r--r-- | lisp/man.el | 71 |
1 files changed, 51 insertions, 20 deletions
diff --git a/lisp/man.el b/lisp/man.el index ac535f0deca..551aad82346 100644 --- a/lisp/man.el +++ b/lisp/man.el | |||
| @@ -397,7 +397,14 @@ that string instead of from the current buffer." | |||
| 397 | 397 | ||
| 398 | (defsubst Man-build-man-command () | 398 | (defsubst Man-build-man-command () |
| 399 | "Builds the entire background manpage and cleaning command." | 399 | "Builds the entire background manpage and cleaning command." |
| 400 | (let ((command (concat manual-program " " Man-switches " %s 2>/dev/null")) | 400 | (let ((command (concat manual-program " " Man-switches |
| 401 | ; Stock MS-DOS shells cannot redirect stderr; | ||
| 402 | ; `call-process' below sends it to /dev/null, | ||
| 403 | ; so we don't need `2>' even with DOS shells | ||
| 404 | ; which do support stderr redirection. | ||
| 405 | (if (not (fboundp 'start-process)) | ||
| 406 | " %s" | ||
| 407 | " %s 2>/dev/null"))) | ||
| 401 | (flist Man-filter-list)) | 408 | (flist Man-filter-list)) |
| 402 | (while (and flist (car flist)) | 409 | (while (and flist (car flist)) |
| 403 | (let ((pcom (car (car flist))) | 410 | (let ((pcom (car (car flist))) |
| @@ -534,10 +541,24 @@ If a buffer already exists for this man page, it will display immediately." | |||
| 534 | (let ((process-environment (copy-sequence process-environment))) | 541 | (let ((process-environment (copy-sequence process-environment))) |
| 535 | ;; Prevent any attempt to use display terminal fanciness. | 542 | ;; Prevent any attempt to use display terminal fanciness. |
| 536 | (setenv "TERM" "dumb") | 543 | (setenv "TERM" "dumb") |
| 537 | (set-process-sentinel | 544 | (if (fboundp 'start-process) |
| 538 | (start-process manual-program buffer "sh" "-c" | 545 | (set-process-sentinel |
| 539 | (format (Man-build-man-command) man-args)) | 546 | (start-process manual-program buffer "sh" "-c" |
| 540 | 'Man-bgproc-sentinel))))) | 547 | (format (Man-build-man-command) man-args)) |
| 548 | 'Man-bgproc-sentinel) | ||
| 549 | (progn | ||
| 550 | (let ((exit-status | ||
| 551 | (call-process shell-file-name nil (list buffer nil) nil "-c" | ||
| 552 | (format (Man-build-man-command) man-args))) | ||
| 553 | (msg "")) | ||
| 554 | (or (and (numberp exit-status) | ||
| 555 | (= exit-status 0)) | ||
| 556 | (and (numberp exit-status) | ||
| 557 | (setq msg | ||
| 558 | (format "exited abnormally with code %d" | ||
| 559 | exit-status))) | ||
| 560 | (setq msg exit-status)) | ||
| 561 | (Man-bgproc-sentinel bufname msg)))))))) | ||
| 541 | 562 | ||
| 542 | (defun Man-notify-when-ready (man-buffer) | 563 | (defun Man-notify-when-ready (man-buffer) |
| 543 | "Notify the user when MAN-BUFFER is ready. | 564 | "Notify the user when MAN-BUFFER is ready. |
| @@ -647,13 +668,20 @@ Same for the ANSI bold and normal escape sequences." | |||
| 647 | (message "%s man page cleaned up" Man-arguments)) | 668 | (message "%s man page cleaned up" Man-arguments)) |
| 648 | 669 | ||
| 649 | (defun Man-bgproc-sentinel (process msg) | 670 | (defun Man-bgproc-sentinel (process msg) |
| 650 | "Manpage background process sentinel." | 671 | "Manpage background process sentinel. |
| 651 | (let ((Man-buffer (process-buffer process)) | 672 | When manpage command is run asynchronously, PROCESS is the process |
| 673 | object for the manpage command; when manpage command is run | ||
| 674 | synchronously, PROCESS is the name of the buffer where the manpage | ||
| 675 | command is run. Second argument MSG is the exit message of the | ||
| 676 | manpage command." | ||
| 677 | (let ((Man-buffer (if (stringp process) (get-buffer process) | ||
| 678 | (process-buffer process))) | ||
| 652 | (delete-buff nil) | 679 | (delete-buff nil) |
| 653 | (err-mess nil)) | 680 | (err-mess nil)) |
| 654 | 681 | ||
| 655 | (if (null (buffer-name Man-buffer)) ;; deleted buffer | 682 | (if (null (buffer-name Man-buffer)) ;; deleted buffer |
| 656 | (set-process-buffer process nil) | 683 | (or (stringp process) |
| 684 | (set-process-buffer process nil)) | ||
| 657 | 685 | ||
| 658 | (save-excursion | 686 | (save-excursion |
| 659 | (set-buffer Man-buffer) | 687 | (set-buffer Man-buffer) |
| @@ -665,17 +693,20 @@ Same for the ANSI bold and normal escape sequences." | |||
| 665 | (progn | 693 | (progn |
| 666 | (end-of-line) (point))) | 694 | (end-of-line) (point))) |
| 667 | delete-buff t)) | 695 | delete-buff t)) |
| 668 | ((not (and (eq (process-status process) 'exit) | 696 | ((or (stringp process) |
| 669 | (= (process-exit-status process) 0))) | 697 | (not (and (eq (process-status process) 'exit) |
| 670 | (setq err-mess | 698 | (= (process-exit-status process) 0)))) |
| 671 | (concat (buffer-name Man-buffer) | 699 | (or (zerop (length msg)) |
| 672 | ": process " | 700 | (progn |
| 673 | (let ((eos (1- (length msg)))) | 701 | (setq err-mess |
| 674 | (if (= (aref msg eos) ?\n) | 702 | (concat (buffer-name Man-buffer) |
| 675 | (substring msg 0 eos) msg)))) | 703 | ": process " |
| 676 | (goto-char (point-max)) | 704 | (let ((eos (1- (length msg)))) |
| 677 | (insert (format "\nprocess %s" msg)) | 705 | (if (= (aref msg eos) ?\n) |
| 678 | ))) | 706 | (substring msg 0 eos) msg)))) |
| 707 | (goto-char (point-max)) | ||
| 708 | (insert (format "\nprocess %s" msg)))) | ||
| 709 | )) | ||
| 679 | (if delete-buff | 710 | (if delete-buff |
| 680 | (kill-buffer Man-buffer) | 711 | (kill-buffer Man-buffer) |
| 681 | (if Man-fontify-manpage-flag | 712 | (if Man-fontify-manpage-flag |
| @@ -684,7 +715,7 @@ Same for the ANSI bold and normal escape sequences." | |||
| 684 | (run-hooks 'Man-cooked-hook) | 715 | (run-hooks 'Man-cooked-hook) |
| 685 | (Man-mode) | 716 | (Man-mode) |
| 686 | (set-buffer-modified-p nil) | 717 | (set-buffer-modified-p nil) |
| 687 | ) | 718 | )) |
| 688 | ;; Restore case-fold-search before calling | 719 | ;; Restore case-fold-search before calling |
| 689 | ;; Man-notify-when-ready because it may switch buffers. | 720 | ;; Man-notify-when-ready because it may switch buffers. |
| 690 | 721 | ||