emacs-devel
[Top][All Lists]
Advanced

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

Should timers run in the initial frame?


From: Adam Porter
Subject: Should timers run in the initial frame?
Date: Mon, 11 Jun 2018 08:40:57 -0500

Hi,

I've learned that Emacs timers run in the context of whichever frame
was most recently active.  This is typically fine, but I've found a
situation in which this may cause problems.

In my new frame-purpose.el package, the buffer-list function is
overridden to only return buffers in the current frame (when
frame-purpose-mode is active, and the frame has a predicate defined in
its parameter list).  This makes it easy to have "purposeful" frames,
because in so-configured frames, commands like ibuffer will only
display buffers matching the configured predicate.

This seems to work fine, but I have noticed that buffer-list gets
called quite often in timers (at least, in my config).  Some of those
timers may do important work, like automatically saving buffers,
network-related tasks that depend on buffers, etc.

So when frame-purpose-mode is active, and the current Emacs frame is a
"purposeful" frame (i.e. not the frame Emacs initially opened, which
has no predicate configured), any timers that fire which iterate over
the result of buffer-list will not see all buffers in the Emacs
process, but only ones matching the frame's predicate.  Thankfully,
real-auto-save-mode (which I use) keeps its own internal list of
buffers, rather than calling buffer-list each time its timer fires.
But I would guess that there are a variety of packages which do
iterate over buffer-list on a timer.

So, I wonder: would it be good if timers ran in the context of the
initially opened Emacs frame, rather than in whichever frame was most
recently active?

Of course, this is likely not a problem for anyone who's not using
frame-purpose.el, i.e. nearly all Emacs users.  However, this might
make Emacs a bit more robust and allow packages like frame-purpose.el
to customize behavior more safely.

Thanks,
Adam



reply via email to

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