[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to execute code after start-process completion?
From: |
Pankaj Jangid |
Subject: |
Re: How to execute code after start-process completion? |
Date: |
Sat, 26 Sep 2020 22:15:47 +0530 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.1.50 (darwin) |
On Sat, Sep 26 2020, Eli Zaretskii wrote:
>> After completion of the process (`notmuch new`), I want to execute some
>> code. As you can see above, I want to put the timestamp in the *Notmuch*
>> buffer. I know that `start-process` returns the process object. But I
>> couldn't find how to use it. Please share any pointers/code-snippet on
>> how to use that object accomplish what I want to do? Or may be there is
>> a different way to do the task. Please advise.
>
> The usual way of doing that is to set up a process-sentinel function.
> It will be called when the process finishes.
Thanks. I am done. Here is my snippet.
#+BEGIN_SRC emacs-lisp
(defun my/timestamp-me (process event)
"Record EVENT in the PROCESS buffer."
(print (format "%s %s at %s" process event (current-time-string))
(process-buffer process)))
(defun my/notmuch-new ()
"Execute 'notmuch new' command and logs in buffer *Notmuch*."
(set-process-sentinel
(start-process "notmuch" "*Notmuch*" "notmuch" "new")
'my/timestamp-me))
#+END_SRC