0

I want to hook into man output (from man.el) but the commands run asynchronously. Does anyone know how to set a process sentinel for the man command, or an alternative to hook the function?

For example, how can I replace the sit-for in the following snippet with a callback to run when man finishes its processing?

(defun get-some-help (cmd &optional num)
  (let ((buf (man (concat (number-to-string (or num 3)) " " cmd))))
    (sit-for 0.1)                       ;how to replace this?
    (unless (buffer-live-p buf)
      (message "Do something else instead"))))

(get-some-help "wait4")
Rorschach
  • 31,301
  • 5
  • 78
  • 129
  • 1
    There *is* a sentinel already, `Man-bgrpoc-sentinel`, and it runs a hook `Man-cooked-hook` so you might be able to add a function to it. However, the hook is run a bit early (see the doc for details or check the man.el source), so I'm not sure whether it'll meet your needs. If worse comes to worse, you can modify `Man-bgproc-sentinel` to run another hook whenever you want it to run and either carry the modification in your tree or submit it as an enhancement to emacs. – NickD Apr 13 '17 at 16:30
  • @Nick thanks, that almost works. I can check there if `buffer-size` is 0. The problem is I can't exit from the function at that point however. – Rorschach Apr 13 '17 at 16:46

0 Answers0