Created
November 23, 2024 17:47
-
-
Save shapr/6500ebfa7bcc4a9e0285a26d1e76ea01 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; run-with-timer is meant to be used when delay is specified in seconds | |
;; this gonna be a list of pairs of | |
;; (cons (time-convert nil 'integer) (current-idle-time)) | |
;; that is, (now-in-unix-time, emacs-idle-time-in-seconds) | |
(defvar fl/activity-intervals nil) | |
;; looks like timers are | |
;; 1. a timer variable | |
(defvar fl/write-interval-timer-var nil) | |
(defun fl/write-interval () | |
(interactive) | |
(setq fl/activity-intervals | |
(cons (cons (time-convert nil 'integer) (current-idle-time)) fl/activity-intervals))) | |
;; 2. a start function | |
(defun fl/write-interval-timer-start () | |
(interactive) | |
;; what does this section do for me? | |
(when (timerp fl/write-interval-timer-var) | |
(cancel-timer fl/write-interval-timer-var)) | |
(setq fl/write-interval-timer-var | |
;; for prototyping, this DOES NOT REPEAT! see the nil below | |
(run-with-timer 10 nil #'fl/write-interval))) | |
;; 3. a stop function | |
(defun fl/write-interval-timer-stop () | |
(interactive) | |
(when (timerp fl/write-interval-timer-var) | |
(cancel-timer fl/write-interval-timer-var) | |
(setq fl/write-interval-timer-var nil))) | |
;; 4. a command that runs the start function | |
(fl/write-interval-timer-start) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment