* How to post-process the buffer populated by the async `start-process'
@ 2019-01-12 3:34 Kaushal Modi
2019-01-12 6:32 ` mail
0 siblings, 1 reply; 3+ messages in thread
From: Kaushal Modi @ 2019-01-12 3:34 UTC (permalink / raw)
To: Help Gnu Emacs mailing list
Hello,
I am using a package which starts a command in a subprocess (async) using
`start-process' and the results of the command are dumped in the buffer arg
passed to subprocess.
But the stdout sent to the buffer has ANSI escape codes.
If I manually visit that buffer, and eval (ansi-color-apply-on-region-int
(point-min) (point-max)), I can see the ANSI color codes nicely rendered.
But I cannot figure out how to do that *when* the start-process initiated
command ends *in* the specified stdout buffer.
If I do:
(apply #'start-process ..)
(with-current-buffer buffer
(ansi-color-apply-on-region-int (point-min) (point-max)) )
.. it of course doesn't work because the a-c-a-o-r-i is getting called
before start-process initiated command ends.
So I somehow need to define a hook that can get triggered when that command
ends, and then call the a-c-a-o-r-i function. But I don't know how.
--
Kaushal Modi
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: How to post-process the buffer populated by the async `start-process'
2019-01-12 3:34 How to post-process the buffer populated by the async `start-process' Kaushal Modi
@ 2019-01-12 6:32 ` mail
2019-01-12 16:10 ` Kaushal Modi
0 siblings, 1 reply; 3+ messages in thread
From: mail @ 2019-01-12 6:32 UTC (permalink / raw)
To: Kaushal Modi, Help Gnu Emacs mailing list
12.01.2019, 11:36, "Kaushal Modi" <kaushal.modi@gmail.com>:
> Hello,
>
> I am using a package which starts a command in a subprocess (async) using
> `start-process' and the results of the command are dumped in the buffer arg
> passed to subprocess.
>
> But the stdout sent to the buffer has ANSI escape codes.
>
> If I manually visit that buffer, and eval (ansi-color-apply-on-region-int
> (point-min) (point-max)), I can see the ANSI color codes nicely rendered.
>
> But I cannot figure out how to do that *when* the start-process initiated
> command ends *in* the specified stdout buffer.
>
> If I do:
>
> (apply #'start-process ..)
> (with-current-buffer buffer
> (ansi-color-apply-on-region-int (point-min) (point-max)) )
>
> .. it of course doesn't work because the a-c-a-o-r-i is getting called
> before start-process initiated command ends.
>
> So I somehow need to define a hook that can get triggered when that command
> ends, and then call the a-c-a-o-r-i function. But I don't know how.
Have you tried (info "(elisp) Sentinels")? The info already provides a nice example, here is another example:
(set-process-sentinel
(start-process "sleep" "*sleep*" "sleep" "3")
(lambda (_process event)
(when (string= event "finished\n")
(message "TODO Do something"))))
> --
> Kaushal Modi
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: How to post-process the buffer populated by the async `start-process'
2019-01-12 6:32 ` mail
@ 2019-01-12 16:10 ` Kaushal Modi
0 siblings, 0 replies; 3+ messages in thread
From: Kaushal Modi @ 2019-01-12 16:10 UTC (permalink / raw)
To: Chunyang Xu; +Cc: Help Gnu Emacs mailing list
On Sat, Jan 12, 2019 at 1:32 AM <mail@xuchunyang.me> wrote:
>
> Have you tried (info "(elisp) Sentinels")? The info already provides a
> nice example, here is another example:
>
> (set-process-sentinel
> (start-process "sleep" "*sleep*" "sleep" "3")
> (lambda (_process event)
> (when (string= event "finished\n")
> (message "TODO Do something"))))
>
I did not know about Sentinels, and your example is much better than that
in the manual :)
Thanks for your help!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-01-12 16:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-12 3:34 How to post-process the buffer populated by the async `start-process' Kaushal Modi
2019-01-12 6:32 ` mail
2019-01-12 16:10 ` Kaushal Modi
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).