unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Invalid or uninitialized timer
@ 2022-12-03 21:47 Heime
  2022-12-03 21:58 ` Gregory Heytings
  0 siblings, 1 reply; 6+ messages in thread
From: Heime @ 2022-12-03 21:47 UTC (permalink / raw)
  To: Heime via Users list for the GNU Emacs text editor


I am really struggling to get a timer working.  

I have the following, but I get "Invalid or uninitialized timer"


(defun ticker-second (lampkl)
  "TODO."

  (interactive)

  (cond
   ((eq 'blue lampkl)
       (insert (propertize "B"
                  'font-lock-face '(:background "blue"
                                    :foreground "white"))))

   ((eq 'green lampkl)
       (insert (propertize "G"
                  'font-lock-face '(:background "green"
                                    :foreground "white")))))

  (insert " "))


  (run-with-timer 0 4 (ticker-second 'blue))



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

* Re: Invalid or uninitialized timer
  2022-12-03 21:47 Invalid or uninitialized timer Heime
@ 2022-12-03 21:58 ` Gregory Heytings
  2022-12-03 22:27   ` Heime
  0 siblings, 1 reply; 6+ messages in thread
From: Gregory Heytings @ 2022-12-03 21:58 UTC (permalink / raw)
  To: Heime; +Cc: help-gnu-emacs


>
> (run-with-timer 0 4 (ticker-second 'blue))
>

(run-with-timer 0 4 #'ticker-second 'blue)



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

* Re: Invalid or uninitialized timer
  2022-12-03 21:58 ` Gregory Heytings
@ 2022-12-03 22:27   ` Heime
  2022-12-03 22:30     ` Gregory Heytings
  0 siblings, 1 reply; 6+ messages in thread
From: Heime @ 2022-12-03 22:27 UTC (permalink / raw)
  To: Gregory Heytings; +Cc: help-gnu-emacs

------- Original Message -------
On Saturday, December 3rd, 2022 at 9:58 PM, Gregory Heytings <gregory@heytings.org> wrote:


> > (run-with-timer 0 4 (ticker-second 'blue))
> 
> 
> (run-with-timer 0 4 #'ticker-second 'blue)

Quite a strange call.




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

* Re: Invalid or uninitialized timer
  2022-12-03 22:27   ` Heime
@ 2022-12-03 22:30     ` Gregory Heytings
  2022-12-03 23:14       ` Heime
  0 siblings, 1 reply; 6+ messages in thread
From: Gregory Heytings @ 2022-12-03 22:30 UTC (permalink / raw)
  To: Heime; +Cc: help-gnu-emacs


>> (run-with-timer 0 4 #'ticker-second 'blue)
>
> Quite a strange call.
>

C-h f run-with-timer RET

(run-with-timer SECS REPEAT FUNCTION &rest ARGS)

Perform an action after a delay of SECS seconds.
Repeat the action every REPEAT seconds, if REPEAT is non-nil.
SECS and REPEAT may be integers or floating point numbers.
The action is to call FUNCTION with arguments ARGS.



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

* Re: Invalid or uninitialized timer
  2022-12-03 22:30     ` Gregory Heytings
@ 2022-12-03 23:14       ` Heime
  2022-12-03 23:21         ` Gregory Heytings
  0 siblings, 1 reply; 6+ messages in thread
From: Heime @ 2022-12-03 23:14 UTC (permalink / raw)
  To: Gregory Heytings; +Cc: help-gnu-emacs

------- Original Message -------
On Saturday, December 3rd, 2022 at 10:30 PM, Gregory Heytings <gregory@heytings.org> wrote:


> > > (run-with-timer 0 4 #'ticker-second 'blue)
> > 
> > Quite a strange call.
> 
> 
> C-h f run-with-timer RET
> 
> (run-with-timer SECS REPEAT FUNCTION &rest ARGS)
> 
> Perform an action after a delay of SECS seconds.
> Repeat the action every REPEAT seconds, if REPEAT is non-nil.
> SECS and REPEAT may be integers or floating point numbers.
> The action is to call FUNCTION with arguments ARGS.

Passing the arguments to function in ARGS took me off guard.



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

* Re: Invalid or uninitialized timer
  2022-12-03 23:14       ` Heime
@ 2022-12-03 23:21         ` Gregory Heytings
  0 siblings, 0 replies; 6+ messages in thread
From: Gregory Heytings @ 2022-12-03 23:21 UTC (permalink / raw)
  To: Heime; +Cc: help-gnu-emacs


>>>> (run-with-timer 0 4 #'ticker-second 'blue)
>>>
>>> Quite a strange call.
>>
>> C-h f run-with-timer RET
>>
>> (run-with-timer SECS REPEAT FUNCTION &rest ARGS)
>>
>> Perform an action after a delay of SECS seconds.
>> Repeat the action every REPEAT seconds, if REPEAT is non-nil.
>> SECS and REPEAT may be integers or floating point numbers.
>> The action is to call FUNCTION with arguments ARGS.
>
> Passing the arguments to function in ARGS took me off guard.
>

You could also opt for a lambda form:

(run-with-timer 0 4 (lambda () (ticker-second 'blue)))



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

end of thread, other threads:[~2022-12-03 23:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-03 21:47 Invalid or uninitialized timer Heime
2022-12-03 21:58 ` Gregory Heytings
2022-12-03 22:27   ` Heime
2022-12-03 22:30     ` Gregory Heytings
2022-12-03 23:14       ` Heime
2022-12-03 23:21         ` Gregory Heytings

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).