In emacs lisp how do I silence "Process python-process finished"
In emacs lisp how do I silence "Process python-process finished"
One simple solution is to “filter” out that message by advising the built‐in message function so that it ignores messages matching "Process … finished". For example, put something like this in your init file: (defun my-silence-python-finished (orig-message fmt &rest args) "Silence messages like \"Process python-process finished\"." (if (and (stringp fmt) (string-match "Process .* finished" fmt)) ;; Do nothing – return nil, which prevents the message. nil (apply orig-message fmt args))) (advice-add 'message :around #'my-silence-python-finished) What this does is whenever some code calls message with a format string, it checks if that string contains “Process … finished” and if so, it simply does nothing. Another approach (if you prefer not to advise ‘message’ globally) is to adjust the process sentinel for your python process so that it doesn’t emit that message. For example, if you can get hold of your python process (say via python-shell-get-process) you might do something like: (when-let ((proc (python-shell-get-process))) (set-process-sentinel proc (lambda (proc event) ;; Only report events that don’t indicate finish. (unless (string-match-p "finished" event) (message "Python process: %s" event))))) Either approach will “silence” the unwanted finished message. Adjust the code to suit your particular workflow. Note: • Using advice on ‘message’ is a global solution so be sure that ignoring messages matching that pattern won’t hide anything else important. • Overriding the process sentinel applies only to that process; if you recreate the process later you may need to reapply it. Either approach should answer your question of how to silence the “Process python-process finished” message in Emacs Lisp.
Testing if the previous output contains the string set-process-sentinel
: True
In emacs lisp how do I silence "Process python-process finished"
In emacs lisp how do I silence "Process python-process finished"
When the Python subprocess ends, Emacs calls its process‐sentinel which in turn prints the "Process python-process finished" message. One common solution is to override that sentinel so that it ignores the “finished” event. For example, you can add something like this to your Emacs Lisp configuration: (defun my/python-process-sentinel (process event) "Filter out the normal finished event from the Python PROCESS." (unless (string-match "finished" event) (message "Python process event: %s" event))) (when (and (get-buffer "*Python*") (get-buffer-process "*Python*")) (set-process-sentinel (get-buffer-process "*Python*") 'my/python-process-sentinel)) In this code: • The function my/python-process-sentinel is defined to only display a message if the event string does not contain "finished". • Then, if there is a Python process associated with the *Python* buffer, we set its process-sentinel to our new function. This will “silence” the normal finished message while still letting you see other (possibly important) process events. You can adjust the matching or the message function as needed. Another approach (depending on your workflow) is to wrap the code that starts or stops python processes with something like (let ((inhibit-message t)) …) so that messages are not shown. However, overriding the process sentinel (as illustrated above) is usually more targeted and preferable. Either way, this is how you can silence the “Process python-process finished” message in Emacs Lisp.
Testing if the previous output contains the string set-process-sentinel
: True