Function: diff-hl--when-done
diff-hl--when-done is a natively compiled function defined in
diff-hl.el.
Signature
(diff-hl--when-done BUFFER GET-VALUE CALLBACK &optional PROC)
Source Code
;; Defined in /nix/store/cfz56rl3lp066226i0bmmgiicls3gcq7-emacs-packages-deps/share/emacs/site-lisp/elpa/diff-hl-20261001.135/diff-hl.el
(defun diff-hl--when-done (buffer get-value callback &optional proc)
(let ((proc (or proc (get-buffer-process buffer))))
(cond
;; If there's no background process, just execute the code.
((or (null proc) (eq (process-status proc) 'exit))
;; Make sure we've read the process's output before going further.
(when proc (accept-process-output proc))
(when (get-buffer buffer)
(with-current-buffer buffer
(funcall callback (funcall get-value buffer)))))
;; If process was deleted, we ignore it.
((eq (process-status proc) 'signal))
;; If a process is running, set the sentinel.
((eq (process-status proc) 'run)
(add-function
:after
(process-sentinel proc)
(lambda (proc _status)
;; Delegate to the parent cond for decision logic.
(diff-hl--when-done buffer get-value callback proc))))
;; Maybe we should ignore all other states as well.
(t (error "Unexpected process state")))))