ellipticcode0 · 2022-06-06 15:45
### Why my Elisp function is not working?
The timer is working
```
(run-with-timer 2 3 (lambda() (message "OK")))
```
Kill the timer
```
(setq timer-list nil)
```
After I kill the timer above, run it with different function
```
(run-with-timer 2 3 (lambda() (thing-at-point 'word 'no-properties)))
```
The above timer is not working
Here is the debug message
```
[nil 25246 7057 361572 3 (closure (t) nil (thing-at-point 'word 'no-properties)) nil nil
```
SlowValue · 2022-06-06 17:03
Try
(run-with-timer 2 3 (lambda() (message (thing-at-point 'word 'no-properties))))
---
> (setq timer-list nil)
Is probably a bad idea since it removes all currently installed timers
---
> [nil 25246 7057 361572 3 (closure (t) nil (thing-at-point 'word 'no-properties)) nil nil
This is no debug message, this is the printed representation of a timer object, you are supposed to store it in a variable to use it later with `cancel-timer`, like so:
(setq foo (run-with-timer 2 3 (lambda() (message (thing-at-point 'word 'no-properties)))))
(cancel-timer foo)
ellipticcode0 · 2022-06-06 17:35
>(run-with-timer 2 3 (lambda() (message (thing-at-point 'word 'no-properties))))
You save my lift :), it works,
Yep, cancel-timer is better