all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Fwd: idle exit hook
       [not found] <20200722113242.577d4nfx4wbbbxxs.ref@ergus>
@ 2020-07-22 11:32 ` Ergus
  2020-07-22 13:59   ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Ergus @ 2020-07-22 11:32 UTC (permalink / raw)
  To: emacs-devel

Hi:

I recently saw a question in reddit but the answer there was not
clear (or maybe it requires a feature request)

Is there an idle-time-exit-hook? or, what's the canonical method to call
a function after breaking an idle? something like on-idle-exit?

So far I understand that having such a hook could produce some
performance penalty but not more than post-command-hook for example. Any
way, adding some restrictions (running it only once || reset the
hooks list on every idle start/end or just documenting it properly)
could solve the problem.. does it makes sense?

The idea came to me when trying to implement my own version of
idle-highlight-mode to propose to add it to vanilla. I would like to
provide a different behaviour.

Best,
Ergus



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

* Re: Fwd: idle exit hook
  2020-07-22 11:32 ` Fwd: idle exit hook Ergus
@ 2020-07-22 13:59   ` Eli Zaretskii
  2020-07-22 22:00     ` Ergus
  0 siblings, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2020-07-22 13:59 UTC (permalink / raw)
  To: Ergus; +Cc: emacs-devel

> Date: Wed, 22 Jul 2020 13:32:42 +0200
> From: Ergus <spacibba@aol.com>
> 
> Is there an idle-time-exit-hook? or, what's the canonical method to call
> a function after breaking an idle? something like on-idle-exit?

How do you define "breaking the idle"?  IOW, what events or activities
will potentially be considered as "breaking the idle"?

> The idea came to me when trying to implement my own version of
> idle-highlight-mode to propose to add it to vanilla. I would like to
> provide a different behaviour.

Not sure why you need a new hook for implementing that behavior.
maybe tell more details about what you intend to implement.



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

* Re: Fwd: idle exit hook
  2020-07-22 13:59   ` Eli Zaretskii
@ 2020-07-22 22:00     ` Ergus
  2020-07-22 22:31       ` Stefan Monnier
  0 siblings, 1 reply; 4+ messages in thread
From: Ergus @ 2020-07-22 22:00 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

On Wed, Jul 22, 2020 at 04:59:24PM +0300, Eli Zaretskii wrote:
>> Date: Wed, 22 Jul 2020 13:32:42 +0200
>> From: Ergus <spacibba@aol.com>
>>
>> Is there an idle-time-exit-hook? or, what's the canonical method to call
>> a function after breaking an idle? something like on-idle-exit?
>
>How do you define "breaking the idle"?  IOW, what events or activities
>will potentially be considered as "breaking the idle"?
>
Hi Eli:

When I say "breaking the idle" I mean any event that potentially could
be considered as not in idle anymore... or anything that resets the idle
counter.

>> The idea came to me when trying to implement my own version of
>> idle-highlight-mode to propose to add it to vanilla. I would like to
>> provide a different behaviour.
>
>Not sure why you need a new hook for implementing that behavior.
>maybe tell more details about what you intend to implement.
>
The idea is extremely simple (that's why I thing it could be in
vanilla). When in idle for some seconds a run-with-idle-timer calls a
function to set a highlight for thing-at-point. (useful when
programming for example)

https://github.com/nonsequitur/idle-highlight-mode/blob/master/idle-highlight-mode.el

The problem with the original implementation (apart from being abandon
and re-implemented by many packages and configuration) is that the
unhighlight function is called only when the idled function is executed
again.

A more common behavior (as in vs-code, atom and so on) is that when we
press any key o perform any action to exit the "highlighted thing"; the
highlight disappears immediately.

This could be performed using a different hook, (post-command-hook) but
it will require add and remove the hook constantly...

WDYT?
Best
Ergus



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

* Re: Fwd: idle exit hook
  2020-07-22 22:00     ` Ergus
@ 2020-07-22 22:31       ` Stefan Monnier
  0 siblings, 0 replies; 4+ messages in thread
From: Stefan Monnier @ 2020-07-22 22:31 UTC (permalink / raw)
  To: Ergus; +Cc: Eli Zaretskii, emacs-devel

> A more common behavior (as in vs-code, atom and so on) is that when we
> press any key o perform any action to exit the "highlighted thing"; the
> highlight disappears immediately.

`pre-command-hook` seems like the obvious choice.

> This could be performed using a different hook, (post-command-hook) but
> it will require add and remove the hook constantly...

Adding/removing from such hooks is very cheap, so it's not a problem.
This said, you can also just leave it on `pre-command-hook` (and set
a variable to indicate when there's nothing to unhighlight).


        Stefan




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

end of thread, other threads:[~2020-07-22 22:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20200722113242.577d4nfx4wbbbxxs.ref@ergus>
2020-07-22 11:32 ` Fwd: idle exit hook Ergus
2020-07-22 13:59   ` Eli Zaretskii
2020-07-22 22:00     ` Ergus
2020-07-22 22:31       ` Stefan Monnier

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.