all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Increasing the rate of modeline display
       [not found] <CAAdUY-LLaSjRgx3FXi1OdrhS6EgBkhrLknjBW5EKMdhuHAJUeA@mail.gmail.com>
@ 2015-03-05 20:24 ` Artur Malabarba
  2015-03-06  8:04   ` Eli Zaretskii
  0 siblings, 1 reply; 9+ messages in thread
From: Artur Malabarba @ 2015-03-05 20:24 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 384 bytes --]

Is there a way to (temporarily) increase the rate at which the mode line is
redisplayed?

I was trying to write a package that adds a spinner to the mode line (to
indicate ongoing operations), but I hit a wall because the mode line
sometimes takes many seconds to redisplay.
I started writing a solution with timers, but that seems like a lot of work
for something so simple.

Cheers

[-- Attachment #2: Type: text/html, Size: 438 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Increasing the rate of modeline display
  2015-03-05 20:24 ` Increasing the rate of modeline display Artur Malabarba
@ 2015-03-06  8:04   ` Eli Zaretskii
  2015-03-06  8:50     ` Artur Malabarba
  2015-03-06  9:12     ` Artur Malabarba
  0 siblings, 2 replies; 9+ messages in thread
From: Eli Zaretskii @ 2015-03-06  8:04 UTC (permalink / raw)
  To: bruce.connor.am; +Cc: emacs-devel

> Date: Thu, 5 Mar 2015 17:24:56 -0300
> From: Artur Malabarba <bruce.connor.am@gmail.com>
> 
> Is there a way to (temporarily) increase the rate at which the mode line is
> redisplayed? 
> 
> I was trying to write a package that adds a spinner to the mode line (to
> indicate ongoing operations), but I hit a wall because the mode line sometimes
> takes many seconds to redisplay.

You cannot increase the rate of redisplay, because it is already "as
fast as possible": Emacs enters redisplay whenever the Lisp
interpreter has nothing else to do.  There are no Emacs-induced delays
that you could slash, AFAIK.

In particular, any time the mode line changes it will be redisplayed
immediately when Emacs has a chance to do so.  "Takes many seconds"
sounds like something I never saw, except when some Lisp code is
running during that time.

If you have Lisp code running and want to initiate redisplay while
Lisp is still running, then yes, it could be a bit tricky.  But it
isn't clear to me that this is your case, especially as you are
talking about "rate".

So I guess you aren't telling us something important that prevents
redisplay from kicking in in your case.  Please add details, or post a
simple self-contained example of the problem.



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Increasing the rate of modeline display
  2015-03-06  8:04   ` Eli Zaretskii
@ 2015-03-06  8:50     ` Artur Malabarba
  2015-03-06  9:12     ` Artur Malabarba
  1 sibling, 0 replies; 9+ messages in thread
From: Artur Malabarba @ 2015-03-06  8:50 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 458 bytes --]

> Lisp is still running, then yes, it could be a bit tricky.  But it
> isn't clear to me that this is your case, especially as you are
> talking about "rate".
>
> So I guess you aren't telling us something important that prevents
> redisplay from kicking in in your case.  Please add details, or post a
> simple self-contained example of the problem.

I'll try with emacs -Q and report back. Maybe something like erc or jabber
was running in the background.

[-- Attachment #2: Type: text/html, Size: 587 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Increasing the rate of modeline display
  2015-03-06  8:04   ` Eli Zaretskii
  2015-03-06  8:50     ` Artur Malabarba
@ 2015-03-06  9:12     ` Artur Malabarba
  2015-03-06  9:13       ` Artur Malabarba
  2015-03-06 10:20       ` Eli Zaretskii
  1 sibling, 2 replies; 9+ messages in thread
From: Artur Malabarba @ 2015-03-06  9:12 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

> You cannot increase the rate of redisplay, because it is already "as
> fast as possible": Emacs enters redisplay whenever the Lisp
> interpreter has nothing else to do.  There are no Emacs-induced delays
> that you could slash, AFAIK.

I think I had my wording wrong. General redisplay works fine (I see
the cursor blinking and stuff like that), but the mode-line content
doesn't update if I'm not interacting. I guess what I want is to
`force-mode-line-redisplay' around once per second (right now, it goes
without update indefinitely if the user is not interacting, see
below).

> In particular, any time the mode line changes it will be redisplayed
> immediately when Emacs has a chance to do so.  "Takes many seconds"
> sounds like something I never saw, except when some Lisp code is
> running during that time.

I ran the following after emacs -Q.

(add-to-list 'mode-line-format
         '(:eval (number-to-string (cadr (current-time))))
         'append)

This adds a number to the mode-line which changes at every second. If
I'm typing text (or otherwise interacting) then I see it updating
fine. If I just take my hands off the keyboard, then the number stops
updating indefinitely.



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Increasing the rate of modeline display
  2015-03-06  9:12     ` Artur Malabarba
@ 2015-03-06  9:13       ` Artur Malabarba
  2015-03-06 10:20       ` Eli Zaretskii
  1 sibling, 0 replies; 9+ messages in thread
From: Artur Malabarba @ 2015-03-06  9:13 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

> `force-mode-line-redisplay' around once per second (right now, it goes

GAAAH! `force-mode-line-update' I mean



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Increasing the rate of modeline display
  2015-03-06  9:12     ` Artur Malabarba
  2015-03-06  9:13       ` Artur Malabarba
@ 2015-03-06 10:20       ` Eli Zaretskii
  2015-03-06 11:20         ` Artur Malabarba
  1 sibling, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2015-03-06 10:20 UTC (permalink / raw)
  To: bruce.connor.am; +Cc: emacs-devel

> Date: Fri, 6 Mar 2015 06:12:27 -0300
> From: Artur Malabarba <bruce.connor.am@gmail.com>
> Cc: emacs-devel <emacs-devel@gnu.org>
> 
> I think I had my wording wrong. General redisplay works fine (I see
> the cursor blinking and stuff like that), but the mode-line content
> doesn't update if I'm not interacting.

Could be a bug: if the contents of mode line changes, Emacs should
redisplay it on the first opportunity.  But see below.

> > In particular, any time the mode line changes it will be redisplayed
> > immediately when Emacs has a chance to do so.  "Takes many seconds"
> > sounds like something I never saw, except when some Lisp code is
> > running during that time.
> 
> I ran the following after emacs -Q.
> 
> (add-to-list 'mode-line-format
>          '(:eval (number-to-string (cadr (current-time))))
>          'append)
> 
> This adds a number to the mode-line which changes at every second. If
> I'm typing text (or otherwise interacting) then I see it updating
> fine. If I just take my hands off the keyboard, then the number stops
> updating indefinitely.

How can Emacs know that the value of the eval form changed?  It can't,
unless it actually eval's it, can it?  When you type, Emacs eval's the
form because other factors cause it do it, that's why you see what you
see.  When nothing happens, Emacs doesn't know that anything on screen
should change, so it doesn't try to see whether the mode line changed,
and doesn't eval the form, because the display engine tries very hard
not to redisplay things that are unchanged, to avoid unpleasant
flickering this causes.

You will see that 'display-time', which does similar things, uses a
timer, which changes the mode-line contents independently of Emacs
recomputing it.

What real-life use case is behind your example?



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Increasing the rate of modeline display
  2015-03-06 10:20       ` Eli Zaretskii
@ 2015-03-06 11:20         ` Artur Malabarba
  2015-03-06 11:34           ` Eli Zaretskii
  2015-03-06 13:24           ` Thien-Thi Nguyen
  0 siblings, 2 replies; 9+ messages in thread
From: Artur Malabarba @ 2015-03-06 11:20 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

> How can Emacs know that the value of the eval form changed?  It can't,
> unless it actually eval's it, can it?

Yes, I understand why the default behavior is like that. I was
wondering whether there was a simple way to change that temporarily
(e.g. have the mode-line update at least once per second).

> You will see that 'display-time', which does similar things, uses a
> timer, which changes the mode-line contents independently of Emacs
> recomputing it.

Thanks for the pointer. I've now resigned to using timers as well
(wasn't terrible, but about half the code is dedicated to that now
=/).

> What real-life use case is behind your example?

I'm writing a package that adds a spinner to the mode-line (some form
of simple ascii animation to indicate that there is an ongoing
operation). For that, I need to update the mode-line every second
(preferably twice per second), while the spinner is active.

Here is the (mostly finished) code: https://github.com/Bruce-Connor/spinner.el



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Increasing the rate of modeline display
  2015-03-06 11:20         ` Artur Malabarba
@ 2015-03-06 11:34           ` Eli Zaretskii
  2015-03-06 13:24           ` Thien-Thi Nguyen
  1 sibling, 0 replies; 9+ messages in thread
From: Eli Zaretskii @ 2015-03-06 11:34 UTC (permalink / raw)
  To: bruce.connor.am; +Cc: emacs-devel

> Date: Fri, 6 Mar 2015 08:20:41 -0300
> From: Artur Malabarba <bruce.connor.am@gmail.com>
> Cc: emacs-devel <emacs-devel@gnu.org>
> 
> > How can Emacs know that the value of the eval form changed?  It can't,
> > unless it actually eval's it, can it?
> 
> Yes, I understand why the default behavior is like that. I was
> wondering whether there was a simple way to change that temporarily
> (e.g. have the mode-line update at least once per second).

We could perhaps add a feature for this kind of applications, if it's
deemed important.  In general, there are options to inhibit redisplay
optimizations, but they are meant for debugging only, and so are
enabled only if you build with --enable-checking=glyphs.

> > You will see that 'display-time', which does similar things, uses a
> > timer, which changes the mode-line contents independently of Emacs
> > recomputing it.
> 
> Thanks for the pointer. I've now resigned to using timers as well
> (wasn't terrible, but about half the code is dedicated to that now
> =/).

Couldn't you just slightly customize display-time instead?  It can be
told to update once a second, perhaps even faster (I didn't try faster
than once a second, though).



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Increasing the rate of modeline display
  2015-03-06 11:20         ` Artur Malabarba
  2015-03-06 11:34           ` Eli Zaretskii
@ 2015-03-06 13:24           ` Thien-Thi Nguyen
  1 sibling, 0 replies; 9+ messages in thread
From: Thien-Thi Nguyen @ 2015-03-06 13:24 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 905 bytes --]

() Artur Malabarba <bruce.connor.am@gmail.com>
() Fri, 6 Mar 2015 08:20:41 -0300

   I've now resigned to using timers as well (wasn't terrible,
   but about half the code is dedicated to that now =/).

See:

 http://lists.gnu.org/archive/html/gnu-emacs-sources/2007-02/msg00006.html

for "fsm", a nice way to abstract these async bits.  I once set
up a half-dozen fsm-based visual geegaws and it was a very smooth
albeit trippy-kitch experience, but hey, [insert Kundera treatise
on life accidents and kitch, here :-D].  YMMV, etc.

I lack bandwidth, but if someone else wants to polish up fsm for
GNU ELPA, i would be happy to mentor (somewhat haphazardly).

-- 
Thien-Thi Nguyen
   GPG key: 4C807502
   (if you're human and you know it)
      read my lisp: (responsep (questions 'technical)
                               (not (via 'mailing-list)))
                     => nil

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-03-06 13:24 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <CAAdUY-LLaSjRgx3FXi1OdrhS6EgBkhrLknjBW5EKMdhuHAJUeA@mail.gmail.com>
2015-03-05 20:24 ` Increasing the rate of modeline display Artur Malabarba
2015-03-06  8:04   ` Eli Zaretskii
2015-03-06  8:50     ` Artur Malabarba
2015-03-06  9:12     ` Artur Malabarba
2015-03-06  9:13       ` Artur Malabarba
2015-03-06 10:20       ` Eli Zaretskii
2015-03-06 11:20         ` Artur Malabarba
2015-03-06 11:34           ` Eli Zaretskii
2015-03-06 13:24           ` Thien-Thi Nguyen

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.