[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Power: blink-cursor-mode is a pig

From: Eli Zaretskii
Subject: Re: Power: blink-cursor-mode is a pig
Date: Fri, 30 Dec 2011 13:42:17 +0200

> Date: Fri, 30 Dec 2011 01:20:45 -0800
> From: Daniel Colascione <address@hidden>
> CC: address@hidden
> Cursor blinking is _not_ implemented at a low level in C; if it were,
> the problem would be more tractable.  The cursor blinking is triggered
> by a lisp timer.  The display code (specifically,
> get_window_cursor_type) can use a different kind of cursor depending on
> whether a window is selected or not; that's why we don't observe the
> cursor blinking when Emacs loses focus.  But the decision to show the
> cursor or not happens on the lisp level, in blink-cursor-timer-function.

Timers are not Lisp-level creatures, they are fully implemented in C.
They just call Lisp functions when the value of some variable becomes
non-positive, but that's all they have to do with Lisp.  It should be
very easy to avoid calling Lisp under some conditions known at the C

But I think I actually don't understand what you are trying to achieve
exactly, and why, because I admit I don't know well what exactly is it
that causes power waste due to "Emacs wakeups" you want to avoid.

Here's what confuses me.  Timers are implemented as part of the Emacs
internal loop that watches the various channels (keyboard, subprocess
pipes, network connections) for available input.  The loop that does
this is always running; it never stops, except for very short periods
of time.  A timer fires when this loop sees that the current time is
past the timer's expiration time.  An idle time fires when the loop
sees that Emacs was idle for more than the specified amount of time
(i.e., the loop records when Emacs became idle and then compares the
current time with that recorded time).  When the loop decides that a
time expired, it calls its Lisp function.

(Btw, unlike what you say, blink-cursor-mode does _not_ use an idle
timer.  But this is not important; I digress.)

Now, in the context of battery operation, why would you want to avoid
calling the Lisp function, given that the loop which invokes that
function will still be running?  How will that avoid waking up Emacs,
when the fact that the loop is running already means Emacs is awake?

What am I missing?

> I don't see anything wrong with this approach.  The only problem is that
> lisp doesn't know when it can turn off the timer.

Turning off the timer does not prevent the above-mentioned loop from
running.  So how would this avoid wasting power?

reply via email to

[Prev in Thread] Current Thread [Next in Thread]