From the Elisp manual at the Sentinels chapter:
The sentinel receives two arguments: the process for which the event occurred, and a string describing the type of event.
But I need it to receive one more argument, because at the end of the process, the context (like current buffer) may have changed.
(defun faustine-mdoc (&optional build-all) "Generate mdoc of the current file, display it in a buffer." (interactive) (let ((files-to-build (if build-all (mapconcat 'identity (project-files (buffer-name) '()) " ") (current-buffer)))) (set-process-sentinel (start-process-shell-command "Mdoc" output-buffer-name (format "command %s" files-to-build)) 'mdoc-sentinel))) (defun mdoc-sentinel (process event) "mdoc sentinel" (let ((pdf-file (format "%s-mdoc/pdf/%s.pdf" (file-name-sans-extension (buffer-name)) ; <- See? This is not the right buffer (file-name-sans-extension (buffer-name))))) (log-to-buffer process event) (when (string-prefix-p "finished" event) (faustine-show pdf-file))))
How can I pass arguments to a sentinel? More generally, how to pass arguments in a quoted function call?