From 5350f06ef4e194a43a9e91444ceb14ec5f4aa4b7 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sat, 5 Apr 2025 10:58:35 +0800 Subject: [PATCH] vc-exec-after: New PROC argument * lisp/vc/vc-dispatcher.el (vc-exec-after): New PROC argument. * lisp/vc/vc-hg.el (vc-exec-after): Update declaration. (cherry picked from commit 3739b86f5af654ec0ae3e47a3662e19ea79d2b3c) --- lisp/vc/vc-dispatcher.el | 17 ++++++++++------- lisp/vc/vc-hg.el | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/lisp/vc/vc-dispatcher.el b/lisp/vc/vc-dispatcher.el index 2db9ea9cbaa..dc71c6c4a9a 100644 --- a/lisp/vc/vc-dispatcher.el +++ b/lisp/vc/vc-dispatcher.el @@ -256,15 +256,18 @@ Another is that undo information is not kept." 'help-echo "A command is in progress in this buffer")))) -(defun vc-exec-after (code &optional success) - "Eval CODE when the current buffer's process is done. -If the current buffer has no process, just evaluate CODE. -Else, add CODE to the process' sentinel. +(defun vc-exec-after (code &optional success proc) + "Execute CODE when PROC, or the current buffer's process, is done. CODE should be a function of no arguments. -If SUCCESS, it should be a process object. Only run CODE if the -SUCCESS process has a zero exit code." - (let ((proc (get-buffer-process (current-buffer)))) +The optional PROC argument specifies the process Emacs should wait for +before executing CODE. It defaults to the current buffer's process. +If PROC is nil and the current buffer has no process, just evaluate +CODE. Otherwise, add CODE to the process's sentinel. + +If SUCCESS, it should be a process object. +Only run CODE if the SUCCESS process has a zero exit code." + (let ((proc (or proc (get-buffer-process (current-buffer))))) (cond ;; If there's no background process, just execute the code. ;; We used to explicitly call delete-process on exited processes, diff --git a/lisp/vc/vc-hg.el b/lisp/vc/vc-hg.el index b7200da0914..a18c463c848 100644 --- a/lisp/vc/vc-hg.el +++ b/lisp/vc/vc-hg.el @@ -1381,7 +1381,7 @@ REV is the revision to check out into WORKFILE." ;; Follows vc-hg-command (or vc-do-async-command), which uses vc-do-command ;; from vc-dispatcher. -(declare-function vc-exec-after "vc-dispatcher" (code &optional success)) +(declare-function vc-exec-after "vc-dispatcher" (code &optional success proc)) ;; Follows vc-exec-after. (declare-function vc-set-async-update "vc-dispatcher" (process-buffer)) -- 2.39.5