* Q: How to programatically terminate repeat-mode
@ 2022-09-09 17:42 T.V Raman
2022-09-10 19:18 ` Juri Linkov
0 siblings, 1 reply; 15+ messages in thread
From: T.V Raman @ 2022-09-09 17:42 UTC (permalink / raw)
To: emacs-devel
I have been using repeat-mode to good effect in emacspeak e.g. in the
context of its media player etc.
One issue I have is that once a command to stop media has been
executed, I'd like the repeat to stop i.e. without me executing
another explicit kbd command like C-g to terminate the repeat.
How do I do this from lisp?
I'd rather not call keyboard-quit explicitly -- that sounds like
overkill?
--
Thanks,
--Raman(I Search, I Find, I Misplace, I Research)
♉ Id: kg:/m/0285kf1 🦮
--
Thanks,
--Raman(I Search, I Find, I Misplace, I Research)
♉ Id: kg:/m/0285kf1 🦮
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Q: How to programatically terminate repeat-mode
2022-09-09 17:42 Q: How to programatically terminate repeat-mode T.V Raman
@ 2022-09-10 19:18 ` Juri Linkov
2022-09-10 19:41 ` T.V Raman
2022-10-02 16:20 ` T.V Raman
0 siblings, 2 replies; 15+ messages in thread
From: Juri Linkov @ 2022-09-10 19:18 UTC (permalink / raw)
To: T.V Raman; +Cc: emacs-devel
> I have been using repeat-mode to good effect in emacspeak e.g. in the
> context of its media player etc.
>
> One issue I have is that once a command to stop media has been
> executed, I'd like the repeat to stop i.e. without me executing
> another explicit kbd command like C-g to terminate the repeat.
The simplest way is just not to put the property 'repeat-map'
on the symbol of the command that stops media. Then executing
this command will terminate the repeat.
> How do I do this from lisp?
It's no easy to do the same from Lisp because in repeat-post-hook
the value of 'exitfun' returned from 'set-transient-map' is not
exposed outside. Maybe the value of 'exitfun' should be stored
in a variable? Currently 'exitfun' is used only by repeat-exit-timer.
> I'd rather not call keyboard-quit explicitly -- that sounds like
> overkill?
Or you could put 'repeat-exit-key' on 'unread-command-events'.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Q: How to programatically terminate repeat-mode
2022-09-10 19:18 ` Juri Linkov
@ 2022-09-10 19:41 ` T.V Raman
2022-09-10 19:44 ` T.V Raman
2022-10-02 16:20 ` T.V Raman
1 sibling, 1 reply; 15+ messages in thread
From: T.V Raman @ 2022-09-10 19:41 UTC (permalink / raw)
To: Juri Linkov; +Cc: emacs-devel
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=gb18030, Size: 1191 bytes --]
Juri Linkov <juri@linkov.net> writes:
will try your suggestions. Would be nice to have a simple API to do
this.
>> I have been using repeat-mode to good effect in emacspeak e.g. in the
>> context of its media player etc.
>>
>> One issue I have is that once a command to stop media has been
>> executed, I'd like the repeat to stop i.e. without me executing
>> another explicit kbd command like C-g to terminate the repeat.
>
> The simplest way is just not to put the property 'repeat-map'
> on the symbol of the command that stops media. Then executing
> this command will terminate the repeat.
>
>> How do I do this from lisp?
>
> It's no easy to do the same from Lisp because in repeat-post-hook
> the value of 'exitfun' returned from 'set-transient-map' is not
> exposed outside. Maybe the value of 'exitfun' should be stored
> in a variable? Currently 'exitfun' is used only by repeat-exit-timer.
>
>> I'd rather not call keyboard-quit explicitly -- that sounds like
>> overkill?
>
> Or you could put 'repeat-exit-key' on 'unread-command-events'.
--
Thanks,
--Raman(I Search, I Find, I Misplace, I Research)
7©4 Id: kg:/m/0285kf1 0Ü8
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Q: How to programatically terminate repeat-mode
2022-09-10 19:41 ` T.V Raman
@ 2022-09-10 19:44 ` T.V Raman
0 siblings, 0 replies; 15+ messages in thread
From: T.V Raman @ 2022-09-10 19:44 UTC (permalink / raw)
To: raman; +Cc: juri, emacs-devel
Works like a charm, that took less than a minute to implement and
test:-)
T.V Raman writes:
> Juri Linkov <juri@linkov.net> writes:
>
> will try your suggestions. Would be nice to have a simple API to do
> this.
>
> >> I have been using repeat-mode to good effect in emacspeak e.g. in the
> >> context of its media player etc.
> >>
> >> One issue I have is that once a command to stop media has been
> >> executed, I'd like the repeat to stop i.e. without me executing
> >> another explicit kbd command like C-g to terminate the repeat.
> >
> > The simplest way is just not to put the property 'repeat-map'
> > on the symbol of the command that stops media. Then executing
> > this command will terminate the repeat.
> >
> >> How do I do this from lisp?
> >
> > It's no easy to do the same from Lisp because in repeat-post-hook
> > the value of 'exitfun' returned from 'set-transient-map' is not
> > exposed outside. Maybe the value of 'exitfun' should be stored
> > in a variable? Currently 'exitfun' is used only by repeat-exit-timer.
> >
> >> I'd rather not call keyboard-quit explicitly -- that sounds like
> >> overkill?
> >
> > Or you could put 'repeat-exit-key' on 'unread-command-events'.
>
> --
>
> Thanks,
>
> --Raman(I Search, I Find, I Misplace, I Research)
> ♉ Id: kg:/m/0285kf1 🦮
--
Thanks,
--Raman(I Search, I Find, I Misplace, I Research)
♉ Id: kg:/m/0285kf1 🦮
--
Thanks,
--Raman(I Search, I Find, I Misplace, I Research)
♉ Id: kg:/m/0285kf1 🦮
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Q: How to programatically terminate repeat-mode
2022-09-10 19:18 ` Juri Linkov
2022-09-10 19:41 ` T.V Raman
@ 2022-10-02 16:20 ` T.V Raman
2022-10-02 17:19 ` T.V Raman
1 sibling, 1 reply; 15+ messages in thread
From: T.V Raman @ 2022-10-02 16:20 UTC (permalink / raw)
To: Juri Linkov; +Cc: emacs-devel
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=gb18030, Size: 1381 bytes --]
Juri Linkov <juri@linkov.net> writes:
Hi,
The suggestion you gave me, ie dont put the repeat property on the
command that stops media works brilliantly --- excpt:
If the media plays to completion while repeat is still active, then the
repeat fails to deactivate. Any ideas on how to handle that?
>> I have been using repeat-mode to good effect in emacspeak e.g. in the
>> context of its media player etc.
>>
>> One issue I have is that once a command to stop media has been
>> executed, I'd like the repeat to stop i.e. without me executing
>> another explicit kbd command like C-g to terminate the repeat.
>
> The simplest way is just not to put the property 'repeat-map'
> on the symbol of the command that stops media. Then executing
> this command will terminate the repeat.
>
>> How do I do this from lisp?
>
> It's no easy to do the same from Lisp because in repeat-post-hook
> the value of 'exitfun' returned from 'set-transient-map' is not
> exposed outside. Maybe the value of 'exitfun' should be stored
> in a variable? Currently 'exitfun' is used only by repeat-exit-timer.
>
>> I'd rather not call keyboard-quit explicitly -- that sounds like
>> overkill?
>
> Or you could put 'repeat-exit-key' on 'unread-command-events'.
--
Thanks,
--Raman(I Search, I Find, I Misplace, I Research)
7©4 Id: kg:/m/0285kf1 0Ü8
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Q: How to programatically terminate repeat-mode
2022-10-02 16:20 ` T.V Raman
@ 2022-10-02 17:19 ` T.V Raman
2022-10-02 18:03 ` Juri Linkov
0 siblings, 1 reply; 15+ messages in thread
From: T.V Raman @ 2022-10-02 17:19 UTC (permalink / raw)
To: Juri Linkov; +Cc: emacs-devel
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=gb18030, Size: 1830 bytes --]
"T.V Raman" <raman@google.com> writes:
Answering my own question:
(push 7 unread-command-events)
in the process sentinel works where I have customized repeat-exit-key
to C-g.
However I needed to explicitly use (push 7 unread-command-events)
rather than the more readable (push repeat-exit-key
unread-command-events)
since unread-command-events doesn't like having a vector pushed onto it.
> Juri Linkov <juri@linkov.net> writes:
> Hi,
>
> The suggestion you gave me, ie dont put the repeat property on the
> command that stops media works brilliantly --- excpt:
>
> If the media plays to completion while repeat is still active, then the
> repeat fails to deactivate. Any ideas on how to handle that?
>
>
>>> I have been using repeat-mode to good effect in emacspeak e.g. in the
>>> context of its media player etc.
>>>
>>> One issue I have is that once a command to stop media has been
>>> executed, I'd like the repeat to stop i.e. without me executing
>>> another explicit kbd command like C-g to terminate the repeat.
>>
>> The simplest way is just not to put the property 'repeat-map'
>> on the symbol of the command that stops media. Then executing
>> this command will terminate the repeat.
>>
>>> How do I do this from lisp?
>>
>> It's no easy to do the same from Lisp because in repeat-post-hook
>> the value of 'exitfun' returned from 'set-transient-map' is not
>> exposed outside. Maybe the value of 'exitfun' should be stored
>> in a variable? Currently 'exitfun' is used only by repeat-exit-timer.
>>
>>> I'd rather not call keyboard-quit explicitly -- that sounds like
>>> overkill?
>>
>> Or you could put 'repeat-exit-key' on 'unread-command-events'.
--
Thanks,
--Raman(I Search, I Find, I Misplace, I Research)
7©4 Id: kg:/m/0285kf1 0Ü8
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Q: How to programatically terminate repeat-mode
2022-10-02 17:19 ` T.V Raman
@ 2022-10-02 18:03 ` Juri Linkov
2022-10-03 0:28 ` T.V Raman
0 siblings, 1 reply; 15+ messages in thread
From: Juri Linkov @ 2022-10-02 18:03 UTC (permalink / raw)
To: T.V Raman; +Cc: emacs-devel
> However I needed to explicitly use (push 7 unread-command-events)
> rather than the more readable (push repeat-exit-key
> unread-command-events)
>
> since unread-command-events doesn't like having a vector pushed onto it.
Actually, the most reliable solution would be to use repeat-exit-timer
because the timer function should run the repeat exit function.
I don't know if there is a function to run the timer function immediately.
The only way that I found is to change the timer's time to 0 seconds,
then the existing timer will fire immediately. For example:
(when repeat-exit-timer
(timer-set-idle-time repeat-exit-timer 0))
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Q: How to programatically terminate repeat-mode
2022-10-02 18:03 ` Juri Linkov
@ 2022-10-03 0:28 ` T.V Raman
2022-10-03 6:56 ` Juri Linkov
0 siblings, 1 reply; 15+ messages in thread
From: T.V Raman @ 2022-10-03 0:28 UTC (permalink / raw)
To: Juri Linkov; +Cc: emacs-devel
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=gb18030, Size: 1148 bytes --]
Juri Linkov <juri@linkov.net> writes:
Replacing the earlier (push 7 unread-command-events)
with
(when repeat-exit-timer
(timer-set-idle-time repeat-exit-timer 0))
in my disable-repeat function that I called from the process-sentinel of
the media player -- with check for exit as the guard condition has no
effect and the repeat remains in effect.
>> However I needed to explicitly use (push 7 unread-command-events)
>> rather than the more readable (push repeat-exit-key
>> unread-command-events)
>>
>> since unread-command-events doesn't like having a vector pushed onto it.
>
> Actually, the most reliable solution would be to use repeat-exit-timer
> because the timer function should run the repeat exit function.
> I don't know if there is a function to run the timer function immediately.
> The only way that I found is to change the timer's time to 0 seconds,
> then the existing timer will fire immediately. For example:
>
> (when repeat-exit-timer
> (timer-set-idle-time repeat-exit-timer 0))
--
Thanks,
--Raman(I Search, I Find, I Misplace, I Research)
7©4 Id: kg:/m/0285kf1 0Ü8
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Q: How to programatically terminate repeat-mode
2022-10-03 0:28 ` T.V Raman
@ 2022-10-03 6:56 ` Juri Linkov
2022-10-03 12:48 ` Stefan Monnier
2022-10-03 14:19 ` T.V Raman
0 siblings, 2 replies; 15+ messages in thread
From: Juri Linkov @ 2022-10-03 6:56 UTC (permalink / raw)
To: T.V Raman; +Cc: emacs-devel
> Replacing the earlier (push 7 unread-command-events)
> with
> (when repeat-exit-timer
> (timer-set-idle-time repeat-exit-timer 0))
>
> in my disable-repeat function that I called from the process-sentinel of
> the media player -- with check for exit as the guard condition has no
> effect and the repeat remains in effect.
Maybe you are starting multiple timers? Currently repeat-mode cancels
all previously started timers, but unfortunately cancel-timer for
repeat-exit-timer doesn't run its timer function that should exit
the repeat map. I propose to add a new optional argument RUN-FUNCTION
to cancel-timer, that will run the timer function after canceling the timer.
This means copying this part of timer-event-handler to cancel-timer:
(save-current-buffer
(apply (timer--function timer) (timer--args timer)))
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Q: How to programatically terminate repeat-mode
2022-10-03 6:56 ` Juri Linkov
@ 2022-10-03 12:48 ` Stefan Monnier
2022-10-03 14:20 ` T.V Raman
2022-10-03 19:56 ` Juri Linkov
2022-10-03 14:19 ` T.V Raman
1 sibling, 2 replies; 15+ messages in thread
From: Stefan Monnier @ 2022-10-03 12:48 UTC (permalink / raw)
To: Juri Linkov; +Cc: T.V Raman, emacs-devel
Juri Linkov [2022-10-03 09:56:32] wrote:
>> Replacing the earlier (push 7 unread-command-events)
>> with
>> (when repeat-exit-timer
>> (timer-set-idle-time repeat-exit-timer 0))
>>
>> in my disable-repeat function that I called from the process-sentinel of
>> the media player -- with check for exit as the guard condition has no
>> effect and the repeat remains in effect.
>
> Maybe you are starting multiple timers? Currently repeat-mode cancels
> all previously started timers, but unfortunately cancel-timer for
> repeat-exit-timer doesn't run its timer function that should exit
> the repeat map. I propose to add a new optional argument RUN-FUNCTION
> to cancel-timer, that will run the timer function after canceling the timer.
> This means copying this part of timer-event-handler to cancel-timer:
I don't see any need to add some weird `run-function` arg to
`cancel-timer`, here.
Why can't the repeat-map code offer a function to ... "programatically
terminate repeat-mode"? Since it set up the timer, it can know what
function the timer will run and with what args and can thus run that
same code if it wants to.
Stefan
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Q: How to programatically terminate repeat-mode
2022-10-03 12:48 ` Stefan Monnier
@ 2022-10-03 14:20 ` T.V Raman
2022-10-03 19:56 ` Juri Linkov
1 sibling, 0 replies; 15+ messages in thread
From: T.V Raman @ 2022-10-03 14:20 UTC (permalink / raw)
To: monnier; +Cc: juri, raman, emacs-devel
yes, API-wise, repeat-mode providing a programmatic means of turning
off a repeat would be best; also I dont think there is a way for a
user to have multiple repeats active, which makes things simpler.
Stefan Monnier writes:
> Juri Linkov [2022-10-03 09:56:32] wrote:
>
> >> Replacing the earlier (push 7 unread-command-events)
> >> with
> >> (when repeat-exit-timer
> >> (timer-set-idle-time repeat-exit-timer 0))
> >>
> >> in my disable-repeat function that I called from the process-sentinel of
> >> the media player -- with check for exit as the guard condition has no
> >> effect and the repeat remains in effect.
> >
> > Maybe you are starting multiple timers? Currently repeat-mode cancels
> > all previously started timers, but unfortunately cancel-timer for
> > repeat-exit-timer doesn't run its timer function that should exit
> > the repeat map. I propose to add a new optional argument RUN-FUNCTION
> > to cancel-timer, that will run the timer function after canceling the timer.
> > This means copying this part of timer-event-handler to cancel-timer:
>
> I don't see any need to add some weird `run-function` arg to
> `cancel-timer`, here.
>
> Why can't the repeat-map code offer a function to ... "programatically
> terminate repeat-mode"? Since it set up the timer, it can know what
> function the timer will run and with what args and can thus run that
> same code if it wants to.
>
>
> Stefan
--
Thanks,
--Raman(I Search, I Find, I Misplace, I Research)
♉ Id: kg:/m/0285kf1 🦮
--
Thanks,
--Raman(I Search, I Find, I Misplace, I Research)
♉ Id: kg:/m/0285kf1 🦮
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Q: How to programatically terminate repeat-mode
2022-10-03 12:48 ` Stefan Monnier
2022-10-03 14:20 ` T.V Raman
@ 2022-10-03 19:56 ` Juri Linkov
2022-10-03 21:41 ` T.V Raman
2022-10-03 23:01 ` T.V Raman
1 sibling, 2 replies; 15+ messages in thread
From: Juri Linkov @ 2022-10-03 19:56 UTC (permalink / raw)
To: Stefan Monnier; +Cc: T.V Raman, emacs-devel
> Why can't the repeat-map code offer a function to ... "programatically
> terminate repeat-mode"? Since it set up the timer, it can know what
> function the timer will run and with what args and can thus run that
> same code if it wants to.
This is what I proposed:
>> How do I do this from lisp?
> Maybe the value of 'exitfun' should be stored in a variable?
So a new variable 'repeat-exit-function' and new function 'repeat-exit'
are added now. Raman, please try to use 'repeat-exit'.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Q: How to programatically terminate repeat-mode
2022-10-03 19:56 ` Juri Linkov
@ 2022-10-03 21:41 ` T.V Raman
2022-10-03 23:01 ` T.V Raman
1 sibling, 0 replies; 15+ messages in thread
From: T.V Raman @ 2022-10-03 21:41 UTC (permalink / raw)
To: juri; +Cc: monnier, raman, emacs-devel
Thanks, will give it a try in the next few days and report back
--
Thanks,
--Raman(I Search, I Find, I Misplace, I Research)
♉ Id: kg:/m/0285kf1 🦮
--
Thanks,
--Raman(I Search, I Find, I Misplace, I Research)
♉ Id: kg:/m/0285kf1 🦮
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Q: How to programatically terminate repeat-mode
2022-10-03 19:56 ` Juri Linkov
2022-10-03 21:41 ` T.V Raman
@ 2022-10-03 23:01 ` T.V Raman
1 sibling, 0 replies; 15+ messages in thread
From: T.V Raman @ 2022-10-03 23:01 UTC (permalink / raw)
To: juri; +Cc: monnier, raman, emacs-devel
Works like a charm -- repeat-exit.
Thanks again for working on this --
--
Thanks,
--Raman(I Search, I Find, I Misplace, I Research)
♉ Id: kg:/m/0285kf1 🦮
--
Thanks,
--Raman(I Search, I Find, I Misplace, I Research)
♉ Id: kg:/m/0285kf1 🦮
--
Thanks,
--Raman(I Search, I Find, I Misplace, I Research)
♉ Id: kg:/m/0285kf1 🦮
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Q: How to programatically terminate repeat-mode
2022-10-03 6:56 ` Juri Linkov
2022-10-03 12:48 ` Stefan Monnier
@ 2022-10-03 14:19 ` T.V Raman
1 sibling, 0 replies; 15+ messages in thread
From: T.V Raman @ 2022-10-03 14:19 UTC (permalink / raw)
To: juri; +Cc: raman, emacs-devel
Dont know that I am starting multiple timer, unless that is it's
happening magically underneath Juri Linkov writes:
> > Replacing the earlier (push 7 unread-command-events)
> > with
> > (when repeat-exit-timer
> > (timer-set-idle-time repeat-exit-timer 0))
> >
> > in my disable-repeat function that I called from the process-sentinel of
> > the media player -- with check for exit as the guard condition has no
> > effect and the repeat remains in effect.
>
> Maybe you are starting multiple timers? Currently repeat-mode cancels
> all previously started timers, but unfortunately cancel-timer for
> repeat-exit-timer doesn't run its timer function that should exit
> the repeat map. I propose to add a new optional argument RUN-FUNCTION
> to cancel-timer, that will run the timer function after canceling the timer.
> This means copying this part of timer-event-handler to cancel-timer:
>
> (save-current-buffer
> (apply (timer--function timer) (timer--args timer)))
--
Thanks,
--Raman(I Search, I Find, I Misplace, I Research)
♉ Id: kg:/m/0285kf1 🦮
--
Thanks,
--Raman(I Search, I Find, I Misplace, I Research)
♉ Id: kg:/m/0285kf1 🦮
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2022-10-03 23:01 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-09 17:42 Q: How to programatically terminate repeat-mode T.V Raman
2022-09-10 19:18 ` Juri Linkov
2022-09-10 19:41 ` T.V Raman
2022-09-10 19:44 ` T.V Raman
2022-10-02 16:20 ` T.V Raman
2022-10-02 17:19 ` T.V Raman
2022-10-02 18:03 ` Juri Linkov
2022-10-03 0:28 ` T.V Raman
2022-10-03 6:56 ` Juri Linkov
2022-10-03 12:48 ` Stefan Monnier
2022-10-03 14:20 ` T.V Raman
2022-10-03 19:56 ` Juri Linkov
2022-10-03 21:41 ` T.V Raman
2022-10-03 23:01 ` T.V Raman
2022-10-03 14:19 ` T.V Raman
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.