From: Madhu <enometh@meer.net>
To: emacs-devel@gnu.org
Subject: Re: undo-auto--undoable-change infloop
Date: Wed, 21 Sep 2022 18:58:08 +0530 [thread overview]
Message-ID: <m3v8pghn6f.fsf@leonis4.robolove.meer.net> (raw)
In-Reply-To: 87y1vwq0su.fsf@web.de
* Michael Heerdegen <87y1vwq0su.fsf @web.de> :
Wrote on Wed, 10 Aug 2022 04:39:45 +0200:
> Stefan Monnier <monnier @iro.umontreal.ca> writes:
>
>> But I think you can `cancel-timer` before `timer-activate`, which will
>> make sure it's not in the list any more.
>
> That solution also came to my mind. Wastes a lot of time, though. The
> `timer-list' is traversed 3 times: First, to find the timer to delete
> it, second to test if it's already present when trying to add it (your
> change), third, to sort it in at the right position (though I don't
> understand why that is necessary). The list is probably never that
> large so that it would matter much.
I didn't spot a bug report but I see this commit:
* commit eb7fe81e6db8d630521098a728713e10c9d59c74
|Author: Stefan Monnier <monnier@iro.umontreal.ca>
|AuthorDate: Fri Aug 5 10:38:59 2022 -0400
|Commit: Stefan Monnier <monnier@iro.umontreal.ca>
|CommitDate: Fri Aug 5 10:38:59 2022 -0400
|
| timer.el: Avoid repeated timers
|
| https://mail.gnu.org/archive/html/emacs-devel/2022-07/msg01127.html
| points out that end-users can get bitten by this, accidentally
| calling `timer-activate` on an already activated timer.
|
| * lisp/emacs-lisp/timer.el (timer--activate): Signal an error if we try
| to re-add a timer that's already on the timer-list.
FYI
I thought I had a valid use case for calling timer--activate on an
already active timer.
```
(defvar $jps-reader-reset-interval 10)
(defvar $current-search-timer
(run-with-timer $jps-reader-reset-interval nil
(lambda ()
(let ((orig $current-search-string))
(setq $current-search-string "")
(let (message-log-max)
(message "timer: reset %s to %s" orig
$current-search-string))))))
(defun respool ()
(progn
;;(find $current-search-timer timer-list)
(setf (timer--time $current-search-timer)
(time-add (seconds-to-time jps-reader-reset-interval) (current-time)))
(timer-activate $current-search-timer)))
```
The idea was to handle a "mode" where keystrokes would enter characters
in a "search string". the "mode" would timeout after a 10 seconds. If a
new character of the "search string" is read within the timeout period,
the timer is renewed ("respooled"). If a non "search string" character
is read, then the timer is cancelled and the "mode" exits.
After this commit the last line of respool has to look like
(timer-activate $current-search-timer nil (cancel-timer-internal
$current-search-timer))
Which uses an internal function, but I thought my timer-activate was
legitimate to extend the timer. Maybe I should have approached the
problem differently?
next prev parent reply other threads:[~2022-09-21 13:28 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-26 3:54 undo-auto--undoable-change infloop Michael Heerdegen
2022-07-26 12:04 ` Eli Zaretskii
2022-07-27 3:52 ` Michael Heerdegen
2022-07-27 4:56 ` Michael Heerdegen
2022-07-27 11:20 ` Eli Zaretskii
2022-07-28 2:51 ` Michael Heerdegen
2022-07-28 3:10 ` Solved (was: undo-auto--undoable-change infloop) Michael Heerdegen
2022-07-28 5:49 ` Eli Zaretskii
2022-07-29 0:40 ` No, not solved " Michael Heerdegen
2022-07-29 3:44 ` No, not solved Michael Heerdegen
2022-07-29 4:12 ` Michael Heerdegen
2022-07-29 6:05 ` No, not solved (was: undo-auto--undoable-change infloop) Eli Zaretskii
2022-07-27 11:20 ` undo-auto--undoable-change infloop Eli Zaretskii
2022-07-27 17:06 ` Michael Heerdegen
2022-07-27 17:34 ` Eli Zaretskii
2022-07-28 2:45 ` Michael Heerdegen
2022-07-29 14:49 ` Stefan Monnier
2022-07-30 1:14 ` Michael Heerdegen
2022-07-30 4:14 ` Michael Heerdegen
2022-07-30 5:54 ` Eli Zaretskii
2022-07-30 7:23 ` Stefan Monnier
2022-07-31 4:05 ` Michael Heerdegen
2022-08-05 14:42 ` Stefan Monnier
2022-08-06 0:26 ` Michael Heerdegen
2022-08-09 4:02 ` Michael Heerdegen
2022-08-09 8:00 ` Stefan Monnier
2022-08-10 2:39 ` Michael Heerdegen
2022-09-21 13:28 ` Madhu [this message]
2022-09-21 14:17 ` timer.el API (was: undo-auto--undoable-change infloop) Stefan Monnier
2022-10-03 20:59 ` timer.el API Michael Heerdegen
2022-10-03 22:10 ` Stefan Monnier
2022-10-03 22:33 ` Michael Heerdegen
2022-10-07 20:50 ` undo-auto--undoable-change infloop Stefan Monnier
2022-10-09 2:32 ` Madhu
2022-10-09 4:23 ` Stefan Monnier
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=m3v8pghn6f.fsf@leonis4.robolove.meer.net \
--to=enometh@meer.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.