* How to execute code after start-process completion?
@ 2020-09-26 14:00 Pankaj Jangid
2020-09-26 14:21 ` Eli Zaretskii
2020-09-26 14:22 ` Daniel Martín
0 siblings, 2 replies; 4+ messages in thread
From: Pankaj Jangid @ 2020-09-26 14:00 UTC (permalink / raw)
To: Emacs Developers
I am working on tiny customization of my Gnus. And using the function
`start-process` to call `notmuch new`.
#+BEGIN_SRC emacs-lisp
(add-hook 'gnus-after-getting-new-news-hook
(lambda ()
(start-process "notmuch" "*Notmuch*" "notmuch" "new")
;; (print (current-time-string) (get-buffer "*Notmuch*"))
))
#+END_SRC
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.
--
Pankaj Jangid
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: How to execute code after start-process completion?
2020-09-26 14:00 How to execute code after start-process completion? Pankaj Jangid
@ 2020-09-26 14:21 ` Eli Zaretskii
2020-09-26 16:45 ` Pankaj Jangid
2020-09-26 14:22 ` Daniel Martín
1 sibling, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2020-09-26 14:21 UTC (permalink / raw)
To: Pankaj Jangid; +Cc: emacs-devel
> From: Pankaj Jangid <pankaj@codeisgreat.org>
> Date: Sat, 26 Sep 2020 19:30:41 +0530
>
> #+BEGIN_SRC emacs-lisp
> (add-hook 'gnus-after-getting-new-news-hook
> (lambda ()
> (start-process "notmuch" "*Notmuch*" "notmuch" "new")
> ;; (print (current-time-string) (get-buffer "*Notmuch*"))
> ))
> #+END_SRC
>
> 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.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: How to execute code after start-process completion?
2020-09-26 14:21 ` Eli Zaretskii
@ 2020-09-26 16:45 ` Pankaj Jangid
0 siblings, 0 replies; 4+ messages in thread
From: Pankaj Jangid @ 2020-09-26 16:45 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: Pankaj Jangid, emacs-devel
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: How to execute code after start-process completion?
2020-09-26 14:00 How to execute code after start-process completion? Pankaj Jangid
2020-09-26 14:21 ` Eli Zaretskii
@ 2020-09-26 14:22 ` Daniel Martín
1 sibling, 0 replies; 4+ messages in thread
From: Daniel Martín @ 2020-09-26 14:22 UTC (permalink / raw)
To: Emacs Developers
Pankaj Jangid <pankaj@codeisgreat.org> writes:
> I am working on tiny customization of my Gnus. And using the function
> `start-process` to call `notmuch new`.
>
> #+BEGIN_SRC emacs-lisp
> (add-hook 'gnus-after-getting-new-news-hook
> (lambda ()
> (start-process "notmuch" "*Notmuch*" "notmuch" "new")
> ;; (print (current-time-string) (get-buffer "*Notmuch*"))
> ))
> #+END_SRC
>
> 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.
You can use a process sentinel for that. Search for "process sentinel"
in the Elisp manual.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-09-26 16:45 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-09-26 14:00 How to execute code after start-process completion? Pankaj Jangid
2020-09-26 14:21 ` Eli Zaretskii
2020-09-26 16:45 ` Pankaj Jangid
2020-09-26 14:22 ` Daniel Martín
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).