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 the name of the buffer where the manpage command is run. 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 the name of the buffer where the manpage
command is run. Second argument MSG is the exit message of the
manpage command."
(let ((Man-buffer (if (stringp process) (get-buffer process)
(process-buffer process)))
(delete-buff nil)
message)
(if (not (buffer-live-p Man-buffer)) ;; deleted buffer
(or (stringp process)
(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 process) 'exit)
(= (process-exit-status process) 0)
(= (point-min) (point-max)))
(setq message (format "%s: no matches" Man-arguments)
delete-buff t))
((or (stringp process)
(not (and (eq (process-status process) 'exit)
(= (process-exit-status process) 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.
(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)))))