timer-list 变量,能帮忙解释一下里面的参数的含义? 第一个参数,nil, 24388, 54032 ,894622,等,
第5个参数是repeat 次数,2/3/4参数好像是时间,这种如何输出可读格式的时间?
timer-list is a variable defined in ‘C source code’.
Its value is
([nil 24388 24178 95578 nil sis--respect-post-cmd-timer-fn nil nil 0]
[nil 24388 24186 430483 nil undo-auto--boundary-timer nil nil 0]
[nil 24388 24201 894622 60 ac-clear-variables-every-minute nil nil 0]
[nil 24388 54032 0 nil circadian-activate-latest-theme nil nil 0])
cireu
2020 年8 月 25 日 02:00
2
;;; timer.el --- run a function with args at some time in future -*- lexical-binding: t -*-
;; Copyright (C) 1996, 2001-2023 Free Software Foundation, Inc.
;; Maintainer: [email protected]
;; Package: emacs
;; This file is part of GNU Emacs.
;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
This file has been truncated. show original
timer是一个用cl-defstruct定义的格式为vector的struct(定义为vector应该是为了兼容),所以用timer--triggered
这些accessor来访问就好了
C-h o timer
timer is a type (of kind cl-structure-class') in
timer.el’.
Instance Allocated Slots:
Name Type Default
———— ———— ———————
triggered t t
high-seconds t nil
low-seconds t nil
usecs t nil
repeat-delay t nil
function t nil
args t nil
idle-delay t nil
psecs t nil
(high-seconds low-seconds usecs)
这三个正好是 Emacs 时间值((elisp) Time of Day ),所以直接用 format-time-string
(format-time-string "%Y-%m-%d %H:%M:%S %z"
'(24388 54032 894622))
;; => "2020-08-25 17:00:00 +0800"
(format-time-string
"%Y-%m-%d %H:%M:%S %z"
(seq-into (seq-subseq (car timer-list) 1 4) 'list))
;; => "2020-08-25 11:45:50 +0800"
如楼上所说,timer 是个结构体,应该用专门的 getter 访问
(mapcar (lambda (f)
(funcall f (car timer-list)))
'(timer--high-seconds
timer--low-seconds
timer--usecs))
;; => (24388 35328 312834)
2 个赞