Function: list-timers

list-timers is an autoloaded, interactive and byte-compiled function defined in timer-list.el.gz.

Signature

(list-timers &optional IGNORE-AUTO NONCONFIRM)

Documentation

List all timers in a buffer.

View in manual

Probably introduced at or before Emacs version 26.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/timer-list.el.gz
;;;###autoload
(defun list-timers (&optional _ignore-auto _nonconfirm)
  "List all timers in a buffer."
  (interactive)
  (pop-to-buffer-same-window (get-buffer-create "*timer-list*"))
  (timer-list-mode)
  (tabulated-list-init-header)
  (setq tabulated-list-entries
        (mapcar
         (lambda (timer)
           (list
            nil
            `[ ;; Idle.
              ,(propertize
                (if (timer--idle-delay timer) "   *" " ")
                'help-echo "* marks idle timers"
                'timer timer)
              ;; Next time.
              ,(propertize
                (let ((time (timer--time timer)))
                  (format "%12s"
                          (format-seconds "%dd %hh %mm %z%,1ss"
                                          (float-time
                                           (if (timer--idle-delay timer)
                                               time
                                             (time-subtract time nil))))))
                'help-echo "Time until next invocation")
              ;; Repeat.
              ,(let ((repeat (timer--repeat-delay timer)))
                 (cond
                  ((numberp repeat)
                   (propertize
                    (format "%12s" (format-seconds
                                    "%x%dd %hh %mm %z%,1ss" repeat))
                    'help-echo "Repeat interval"))
                  ((null repeat)
                   (propertize "           -" 'help-echo "Runs once"))
                  (t
                   (format "%12s" repeat))))
              ;; Function.
              ,(propertize
                (let ((cl-print-compiled 'static)
                      (cl-print-compiled-button nil)
                      (print-escape-newlines t))
                  (cl-prin1-to-string (timer--function timer)))
                'help-echo "Function called by timer")]))
         (append timer-list timer-idle-list)))
  (tabulated-list-print))