Function: Man-bgproc-sentinel
Man-bgproc-sentinel is a byte-compiled function defined in man.el.gz.
Signature
(Man-bgproc-sentinel PROCESS MSG)
Documentation
Manpage background process sentinel.
When manpage command is run asynchronously, PROCESS is the process object for the manpage command; when manpage command is run synchronously, PROCESS is a cons (BUFFER . EXIT-STATUS) of the buffer where the manpage command has run and the exit status of the manpage command. Second argument MSG is the exit message of the manpage command.
Source Code
;; Defined in /usr/src/emacs/lisp/man.el.gz
(defun Man-bgproc-sentinel (process msg)
"Manpage background process sentinel.
When manpage command is run asynchronously, PROCESS is the process
object for the manpage command; when manpage command is run
synchronously, PROCESS is a cons (BUFFER . EXIT-STATUS) of the buffer
where the manpage command has run and the exit status of the manpage
command. Second argument MSG is the exit message of the manpage
command."
(let ((asynchronous (processp process))
Man-buffer process-status exit-status
(delete-buff nil)
message)
(if asynchronous
(setq Man-buffer (process-buffer process)
process-status (process-status process)
exit-status (process-exit-status process))
(setq Man-buffer (car process)
process-status 'exit
exit-status (cdr process)))
(if (not (buffer-live-p Man-buffer)) ;; deleted buffer
(and asynchronous
(set-process-buffer process nil))
(with-current-buffer Man-buffer
(save-excursion
(let ((case-fold-search nil)
(inhibit-read-only t))
(goto-char (point-min))
(cond ((or (looking-at "No \\(manual \\)*entry for")
(looking-at "[^\n]*: nothing appropriate$"))
(setq message (buffer-substring (point)
(progn
(end-of-line) (point)))
delete-buff t))
;; "-k foo", successful exit, but no output (from man-db)
;; ENHANCE-ME: share the check for -k with
;; `Man-highlight-references'. The \\s- bits here are
;; meant to allow for multiple options with -k among them.
((and (string-match "\\(\\`\\|\\s-\\)-k\\s-" Man-arguments)
(eq process-status 'exit)
(= exit-status 0)
(= (point-min) (point-max)))
(setq message (format "%s: no matches" Man-arguments)
delete-buff t))
((not (and (eq process-status 'exit)
(= exit-status 0)))
(or (zerop (length msg))
(progn
(setq message
(concat (buffer-name Man-buffer)
": process "
(let ((eos (1- (length msg))))
(if (= (aref msg eos) ?\n)
(substring msg 0 eos) msg))))
(goto-char (point-max))
(insert (format "\nprocess %s" msg))))
))
(unless delete-buff
(run-hooks 'Man-cooked-hook)
(Man-build-page-list)
(Man-strip-page-headers)
(Man-unindent)
(Man-goto-page 1 t)
(if (not Man-page-list)
(let ((args Man-arguments))
(setq delete-buff t)
;; Entries hyphenated due to the window's width
;; won't be found in the man database, so remove
;; the hyphenation -- assuming Groff hyphenates
;; either with hyphen-minus (ASCII 45, #x2d),
;; hyphen (#x2010) or soft hyphen (#xad) -- and
;; look again.
(if (string-match "[-‐]" args)
(let ((str (replace-match "" nil nil args)))
(Man-getpage-in-background str))
(setq message (format "Can't find the %s manpage"
(Man-page-from-arguments args)))))
(if Man-fontify-manpage-flag
(setq message (format "%s man page formatted"
(Man-page-from-arguments Man-arguments)))
(setq message (format "%s man page cleaned up"
(Man-page-from-arguments Man-arguments))))
(unless (and (processp process)
(not (eq (process-status process) 'exit)))
(setq mode-line-process nil))
(set-buffer-modified-p nil))))))
(when delete-buff
(if (window-live-p (get-buffer-window Man-buffer t))
(progn
(quit-restore-window
(get-buffer-window Man-buffer t) 'kill)
;; Ensure that we end up in the correct window. Which is
;; only relevant in rather special cases and if we have
;; been called in an asynchronous fashion, see bug#38164.
(and asynchronous
(let ((old-window (old-selected-window)))
(when (window-live-p old-window)
(select-window old-window)))))
(kill-buffer Man-buffer)))
(when message
(message "%s" message)))))