all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Adam Porter <adam@alphapapa.net>
To: emacs-devel@gnu.org
Subject: Should timers run in the initial frame?
Date: Mon, 11 Jun 2018 08:40:57 -0500	[thread overview]
Message-ID: <CAO_b3FXrEXorY9Jp0LpZ4Miefrr1ZJ9V+4HJazHZ9fZGav-esA@mail.gmail.com> (raw)

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	other threads:[~2018-06-11 13:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-11 13:40 Adam Porter [this message]
2018-06-11 15:42 ` Should timers run in the initial frame? Stefan Monnier
2018-06-16 21:07   ` Daniel Colascione

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAO_b3FXrEXorY9Jp0LpZ4Miefrr1ZJ9V+4HJazHZ9fZGav-esA@mail.gmail.com \
    --to=adam@alphapapa.net \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.