Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs automating function based on timer: user disturbance

Tags:

emacs

r

elisp

gnus

I am looking for a general way for Emacs to do some checks, and (bing) when something is true or false.

I have 2 examples at the moment. There is an auction website, and I figured it would be nice for Emacs to check whether there has been an update. I did this using R (Emacs-ESS) to load source code of the website. Then I use a selfmade function in Emacs to:

Switch buffer, reload the URL info, send the info to the screen, (sleep-for ) to wait a little. Search for "Today". Then it has to check the value after this string, if it is higher than 0, then it means I have something new of interest, and it PINGS.

This is a long introduction, but I really like that this works.

I now do the same with Gnus, I have a timer that runs a function that opens Gnus every 10 seconds, searches for "Inbox", checks the value, and if it is higher than 0 then it notifies me (otherwise it just switches the buffer back). The only problem is that this takes around 0.5 seconds, in which you can see point move to another buffer and switch back.

Is there a general approach to have these automated things be done, without disturbing the user?

EDIT: Wouldn't it be nice for Emacs to perform a check to see whether there is a new post with our favorite tag here on Stackoverflow?

like image 557
PascalVKooten Avatar asked Feb 23 '26 01:02

PascalVKooten


1 Answers

Emacs is single-threaded, so we are screwed - there is not way to do this without bothering the user at all.

The trick is to select a good balance between the frequency and cost of the check so that the user can bear it.

like image 154
sds Avatar answered Feb 24 '26 16:02

sds



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!