* Updating frame on gnus-group-get-new-news
@ 2017-10-25 22:49 Michael Baer
2017-10-28 1:19 ` Eric Abrahamsen
0 siblings, 1 reply; 3+ messages in thread
From: Michael Baer @ 2017-10-25 22:49 UTC (permalink / raw)
To: ding
I think I'm missing something obvious and I hoped someone here could
help point it out to me. I have function to run offlineimap and then
gnus-group-get-new-news. When I run the function the gnus group frame
isn't updated with the new mail folder info (e.g. number of unread mail
/ total number of mail, etc.). If I run M-x gnus-group-get-new-news or
just 'g' afterwords, the frame is updated as expected. It just doesn't
update from the gnus-group-get-new-news in my function. The function is
listed below.
Gnus v5.13
GNU Emacs 25.3.1 (x86_64-redhat-linux-gnu, GTK+ Version 3.22.17) of 2017-09-14
(defun cc-offlineimap-and-get-news ()
(interactive)
(gnus-group-get-new-news)
(shell-command "dotopright.pl 'time offlineimap; sleep 4'")
(gnus-group-get-new-news)
)
[ dotopright.pl just figures out where to put a terminal on the screen
and then opens the terminal running the passed in command ]
-Mike
--
Michael Baer
gnus@mikesoffice.com
omnes deorsum absurdo est
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Updating frame on gnus-group-get-new-news
2017-10-25 22:49 Updating frame on gnus-group-get-new-news Michael Baer
@ 2017-10-28 1:19 ` Eric Abrahamsen
2017-10-30 20:02 ` solution Michael Baer
0 siblings, 1 reply; 3+ messages in thread
From: Eric Abrahamsen @ 2017-10-28 1:19 UTC (permalink / raw)
To: ding
Michael Baer <gnus@mikesoffice.com> writes:
> I think I'm missing something obvious and I hoped someone here could
> help point it out to me. I have function to run offlineimap and then
> gnus-group-get-new-news. When I run the function the gnus group frame
> isn't updated with the new mail folder info (e.g. number of unread mail
> / total number of mail, etc.). If I run M-x gnus-group-get-new-news or
> just 'g' afterwords, the frame is updated as expected. It just doesn't
> update from the gnus-group-get-new-news in my function. The function is
> listed below.
>
> Gnus v5.13
> GNU Emacs 25.3.1 (x86_64-redhat-linux-gnu, GTK+ Version 3.22.17) of 2017-09-14
>
>
> (defun cc-offlineimap-and-get-news ()
> (interactive)
> (gnus-group-get-new-news)
> (shell-command "dotopright.pl 'time offlineimap; sleep 4'")
> (gnus-group-get-new-news)
> )
I don't know exactly what's going wrong here, but I have to assume that
there's a timing mismatch between the `shell-command', and your second
`gnus-group-get-new-news'. It's true that `shell-command' is meant to be
synchronous, so it ought to work, but you'll be better off using the
tools specifically meant for these situations. That would probably be a
combination of `start-process-shell-command' and sentinels.
This is totally untested:
(defun cc-offlineimap-and-get-news ()
(interactive)
(let ((proc (start-process-shell-command
"offlimap" nil "dotopright.pl 'time offlineimap'")))
(set-process-sentinel
proc (lambda (proc event)
(when (string-prefix-p "finished" event)
(gnus-group-get-new-news))))))
That also allows you to handle different events in the sentinel
callback, popping up a buffer if things go wrong, etc.
Like I said, untested, but something like that should get you there.
Eric
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: solution
2017-10-28 1:19 ` Eric Abrahamsen
@ 2017-10-30 20:02 ` Michael Baer
0 siblings, 0 replies; 3+ messages in thread
From: Michael Baer @ 2017-10-30 20:02 UTC (permalink / raw)
To: Eric Abrahamsen; +Cc: ding
>>>>> On Fri, 27 Oct 2017 18:19:35 -0700, Eric Abrahamsen <eric@ericabrahamsen.net> said:
Eric> Michael Baer <gnus@mikesoffice.com> writes:
>> I think I'm missing something obvious and I hoped someone here could
>> help point it out to me. I have function to run offlineimap and then
>> gnus-group-get-new-news. When I run the function the gnus group frame
>> isn't updated with the new mail folder info (e.g. number of unread mail
>> / total number of mail, etc.). If I run M-x gnus-group-get-new-news or
>> just 'g' afterwords, the frame is updated as expected. It just doesn't
>> update from the gnus-group-get-new-news in my function. The function is
>> listed below.
>>
>> Gnus v5.13
>> GNU Emacs 25.3.1 (x86_64-redhat-linux-gnu, GTK+ Version 3.22.17) of 2017-09-14
>>
>>
>> (defun cc-offlineimap-and-get-news ()
>> (interactive)
>> (gnus-group-get-new-news)
>> (shell-command "dotopright.pl 'time offlineimap; sleep 4'")
>> (gnus-group-get-new-news)
>> )
Eric> I don't know exactly what's going wrong here, but I have to assume that
Eric> there's a timing mismatch between the `shell-command', and your second
Eric> `gnus-group-get-new-news'. It's true that `shell-command' is meant to be
Eric> synchronous, so it ought to work, but you'll be better off using the
Eric> tools specifically meant for these situations. That would probably be a
Eric> combination of `start-process-shell-command' and sentinels.
Eric> This is totally untested:
Eric> (defun cc-offlineimap-and-get-news ()
Eric> (interactive)
Eric> (let ((proc (start-process-shell-command
Eric> "offlimap" nil "dotopright.pl 'time offlineimap'")))
Eric> (set-process-sentinel
Eric> proc (lambda (proc event)
Eric> (when (string-prefix-p "finished" event)
Eric> (gnus-group-get-new-news))))))
Eric> That also allows you to handle different events in the sentinel
Eric> callback, popping up a buffer if things go wrong, etc.
Eric> Like I said, untested, but something like that should get you there.
Eric> Eric
Thanks Eric, that got me thinking along the right path.
Just as an FYI for anyone, the problem seemed to be a combination of the
Perl script and running the commands in a terminal (I think the
terminal) One of those caused the commands to run asynchronously.
If I run the commands without the perl-script/terminal, it works
synchronously as expected.
-Mike
--
Michael Baer
gnus@mikesoffice.com
omnes deorsum absurdo est
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-10-30 20:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-25 22:49 Updating frame on gnus-group-get-new-news Michael Baer
2017-10-28 1:19 ` Eric Abrahamsen
2017-10-30 20:02 ` solution Michael Baer
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 NNTP newsgroup(s).