2016-10-31 20:31:22 -04:00
|
|
|
|
;;; timer.el --- run a function with args at some time in future -*- lexical-binding: t -*-
|
2003-05-30 23:31:15 +00:00
|
|
|
|
|
2023-01-01 05:31:12 -05:00
|
|
|
|
;; Copyright (C) 1996, 2001-2023 Free Software Foundation, Inc.
|
2003-05-30 23:31:15 +00:00
|
|
|
|
|
2019-05-25 13:43:06 -07:00
|
|
|
|
;; Maintainer: emacs-devel@gnu.org
|
2010-08-29 12:17:13 -04:00
|
|
|
|
;; Package: emacs
|
2003-05-30 23:31:15 +00:00
|
|
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
|
2008-05-06 03:21:21 +00:00
|
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
2003-05-30 23:31:15 +00:00
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
2008-05-06 03:21:21 +00:00
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
2003-05-30 23:31:15 +00:00
|
|
|
|
|
|
|
|
|
;; 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
|
2017-09-13 15:52:52 -07:00
|
|
|
|
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
2003-05-30 23:31:15 +00:00
|
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
|
|
;; This package gives you the capability to run Emacs Lisp commands at
|
|
|
|
|
;; specified times in the future, either as one-shots or periodically.
|
|
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
2012-06-10 09:28:26 -04:00
|
|
|
|
(eval-when-compile (require 'cl-lib))
|
2008-04-03 03:43:18 +00:00
|
|
|
|
|
2021-08-31 03:04:22 +02:00
|
|
|
|
;; If you change this structure, you also have to change `timerp'
|
|
|
|
|
;; (below) and decode_timer in keyboard.c.
|
2012-06-10 09:28:26 -04:00
|
|
|
|
(cl-defstruct (timer
|
2013-04-10 09:31:35 -04:00
|
|
|
|
(:constructor nil)
|
|
|
|
|
(:copier nil)
|
2021-09-03 19:41:23 -04:00
|
|
|
|
(:constructor timer--create ())
|
2013-04-10 09:31:35 -04:00
|
|
|
|
(:type vector)
|
|
|
|
|
(:conc-name timer--))
|
|
|
|
|
;; nil if the timer is active (waiting to be triggered),
|
|
|
|
|
;; non-nil if it is inactive ("already triggered", in theory).
|
2008-04-03 03:43:18 +00:00
|
|
|
|
(triggered t)
|
2013-04-10 09:31:35 -04:00
|
|
|
|
;; Time of next trigger: for normal timers, absolute time, for idle timers,
|
|
|
|
|
;; time relative to idle-start.
|
|
|
|
|
high-seconds low-seconds usecs
|
|
|
|
|
;; For normal timers, time between repetitions, or nil. For idle timers,
|
|
|
|
|
;; non-nil iff repeated.
|
|
|
|
|
repeat-delay
|
|
|
|
|
function args ;What to do when triggered.
|
|
|
|
|
idle-delay ;If non-nil, this is an idle-timer.
|
2021-08-31 03:04:22 +02:00
|
|
|
|
psecs
|
2021-09-21 22:11:43 +02:00
|
|
|
|
;; A timer may be created with t as the TIME, which means that we
|
2021-08-31 03:04:22 +02:00
|
|
|
|
;; want to run at specific integral multiples of `repeat-delay'. We
|
|
|
|
|
;; then have to recompute this (because the machine may have gone to
|
|
|
|
|
;; sleep, etc).
|
|
|
|
|
integral-multiple)
|
2003-05-30 23:31:15 +00:00
|
|
|
|
|
2021-09-03 19:41:23 -04:00
|
|
|
|
(defun timer-create ()
|
|
|
|
|
;; BEWARE: This is not an eta-redex, because `timer--create' is inlinable
|
|
|
|
|
;; whereas `timer-create' should not be because we don't want to
|
|
|
|
|
;; hardcode the shape of timers in other .elc files.
|
|
|
|
|
(timer--create))
|
|
|
|
|
|
2003-05-30 23:31:15 +00:00
|
|
|
|
(defun timerp (object)
|
|
|
|
|
"Return t if OBJECT is a timer."
|
2021-09-03 10:40:21 +02:00
|
|
|
|
(and (vectorp object)
|
|
|
|
|
;; Timers are now ten elements, but old .elc code may have
|
|
|
|
|
;; shorter versions of `timer-create'.
|
|
|
|
|
(<= 9 (length object) 10)))
|
2003-05-30 23:31:15 +00:00
|
|
|
|
|
2013-04-10 09:31:35 -04:00
|
|
|
|
(defsubst timer--check (timer)
|
|
|
|
|
(or (timerp timer) (signal 'wrong-type-argument (list #'timerp timer))))
|
|
|
|
|
|
2013-08-12 22:30:52 -04:00
|
|
|
|
(defun timer--time-setter (timer time)
|
|
|
|
|
(timer--check timer)
|
New function time-convert
This replaces the awkward reuse of encode-time to both convert
calendrical timestamps to Lisp timestamps, and to convert Lisp
timestamps to other forms. Now, encode-time does just the
former and the new function does just the latter.
The new function builds on a suggestion by Lars Ingebrigtsen in:
https://lists.gnu.org/r/emacs-devel/2019-07/msg00801.html
and refined by Stefan Monnier in:
https://lists.gnu.org/r/emacs-devel/2019-07/msg00803.html
* doc/lispref/os.texi (Time of Day, Time Conversion):
* doc/misc/emacs-mime.texi (time-date):
* etc/NEWS: Update documentation.
* lisp/calendar/cal-dst.el (calendar-next-time-zone-transition):
* lisp/calendar/time-date.el (seconds-to-time, days-to-time):
* lisp/calendar/timeclock.el (timeclock-seconds-to-time):
* lisp/cedet/ede/detect.el (ede-detect-qtest):
* lisp/completion.el (cmpl-hours-since-origin):
* lisp/ecomplete.el (ecomplete-add-item):
* lisp/emacs-lisp/cl-extra.el (cl--random-time):
* lisp/emacs-lisp/timer.el (timer--time-setter)
(timer-next-integral-multiple-of-time):
* lisp/find-lisp.el (find-lisp-format-time):
* lisp/gnus/gnus-diary.el (gnus-user-format-function-d):
* lisp/gnus/gnus-group.el (gnus-group-set-timestamp):
* lisp/gnus/gnus-icalendar.el (gnus-icalendar-show-org-agenda):
* lisp/gnus/nnrss.el (nnrss-normalize-date):
* lisp/gnus/nnspool.el (nnspool-request-newgroups):
* lisp/net/ntlm.el (ntlm-compute-timestamp):
* lisp/net/pop3.el (pop3-uidl-dele):
* lisp/obsolete/vc-arch.el (vc-arch-add-tagline):
* lisp/org/org-clock.el (org-clock-get-clocked-time)
(org-clock-resolve, org-resolve-clocks, org-clock-in)
(org-clock-out, org-clock-sum):
* lisp/org/org-id.el (org-id-uuid, org-id-time-to-b36):
* lisp/org/ox-publish.el (org-publish-cache-ctime-of-src):
* lisp/proced.el (proced-format-time):
* lisp/progmodes/cc-cmds.el (c-progress-init)
(c-progress-update):
* lisp/progmodes/cperl-mode.el (cperl-time-fontification):
* lisp/progmodes/flymake.el (flymake--schedule-timer-maybe):
* lisp/progmodes/vhdl-mode.el (vhdl-update-progress-info)
(vhdl-fix-case-region-1):
* lisp/tar-mode.el (tar-octal-time):
* lisp/time.el (emacs-uptime):
* lisp/url/url-auth.el (url-digest-auth-make-cnonce):
* lisp/url/url-util.el (url-lazy-message):
* lisp/vc/vc-cvs.el (vc-cvs-parse-entry):
* lisp/vc/vc-hg.el (vc-hg-state-fast):
* lisp/xt-mouse.el (xterm-mouse-event):
* test/lisp/emacs-lisp/timer-tests.el:
(timer-next-integral-multiple-of-time-2):
Use time-convert, not encode-time.
* lisp/calendar/icalendar.el (icalendar--decode-isodatetime):
Don’t use now-removed FORM argument for encode-time.
It wasn’t crucial anyway.
* lisp/emacs-lisp/byte-opt.el (side-effect-free-fns): Add time-convert.
* lisp/emacs-lisp/elint.el (elint-unknown-builtin-args):
Update encode-time signature to match current arg set.
* lisp/emacs-lisp/timer.el (timer-next-integral-multiple-of-time):
Use timer-convert with t rather than doing it by hand.
* src/timefns.c (time_hz_ticks, time_form_stamp, lisp_time_form_stamp):
Remove; no longer needed.
(decode_lisp_time): Rturn the form instead of having a *PFORM arg.
All uses changed.
(time_arith): Just return TICKS if HZ is 1.
(Fencode_time): Remove argument FORM. All callers changed.
Do not attempt to encode time values; just encode
decoded (calendrical) times.
Unless CURRENT_TIME_LIST, just return VALUE since HZ is 1.
(Ftime_convert): New function, which does the time value
conversion that bleeding-edge encode-time formerly did.
Return TIME if it is easy to see that it is already
of the correct form.
(Fcurrent_time): Mention in doc that the form is planned to change.
* test/src/timefns-tests.el (decode-then-encode-time):
Don’t use (encode-time nil).
2019-08-05 17:38:52 -07:00
|
|
|
|
(let ((lt (time-convert time 'list)))
|
New (TICKS . HZ) timestamp format
This follows on a suggestion by Stefan Monnier in:
https://lists.gnu.org/r/emacs-devel/2018-08/msg00991.html
(Bug#32902).
* doc/lispref/buffers.texi (Modification Time):
* doc/lispref/os.texi (Processor Run Time, Time Calculations)
* doc/lispref/processes.texi (System Processes):
* doc/lispref/text.texi (Undo):
Let the "Time of Day" section cover timestamp format details.
* doc/lispref/os.texi (Time of Day):
Say that timestamp internal format should not be assumed.
Document new (ticks . hz) format. Omit mention of seconds-to-time
since it is now just an alias for encode-time.
(Time Conversion): Document encode-time extension.
* etc/NEWS: Mention changes.
* lisp/calendar/cal-dst.el (calendar-system-time-basis): Now const.
* lisp/calendar/cal-dst.el (calendar-absolute-from-time)
(calendar-time-from-absolute)
(calendar-next-time-zone-transition):
* lisp/emacs-lisp/timer.el (timer-next-integral-multiple-of-time):
Simplify by using bignums, (TICKS . HZ), and new encode-time.
* lisp/emacs-lisp/timer.el (timer-next-integral-multiple-of-time):
Simplify by using bignums and new encode-time.
* lisp/calendar/parse-time.el (parse-iso8601-time-string):
Handle DST more accurately, by using new encode-time.
* lisp/calendar/time-date.el (seconds-to-time):
* lisp/calendar/timeclock.el (timeclock-seconds-to-time):
Now just an alias for encode-time.
* lisp/calendar/time-date.el (days-to-time):
* lisp/emacs-lisp/timer.el (timer--time-setter):
* lisp/net/ntlm.el (ntlm-compute-timestamp):
* lisp/obsolete/vc-arch.el (vc-arch-add-tagline):
* lisp/org/org-id.el (org-id-uuid, org-id-time-to-b36):
* lisp/tar-mode (tar-octal-time):
Don't assume timestamps default to list form.
* lisp/tar-mode.el (tar-parse-octal-long-integer):
Now an obsolete alias for tar-parse-octal-integer.
* src/keyboard.c (decode_timer): Adjust to changes to
time decoding functions elsewhere.
* src/timefns.c: Include bignum.h, limits.h.
(FASTER_TIMEFNS): New macro.
(WARN_OBSOLETE_TIMESTAMPS, CURRENT_TIME_LIST)
(timespec_hz, trillion, ztrillion):
New constants.
(make_timeval): Use TIME_T_MAX instead of its definiens.
(check_time_validity, time_add, time_subtract):
Remove. All uses removed.
(disassemble_lisp_time): Remove; old code now folded into
decode_lisp_time. All callers changed.
(invalid_hz, s_ns_to_double, ticks_hz_list4, mpz_set_time)
(timespec_mpz, timespec_ticks, time_hz_ticks)
(lisp_time_hz_ticks, lisp_time_seconds)
(time_form_stamp, lisp_time_form_stamp, decode_ticks_hz)
(decode_lisp_time, mpz_time, list4_to_timespec):
New functions.
(decode_float_time, decode_time_components, lisp_to_timespec):
Adjust to new struct lisp_time, which does not lose
information like the old one did.
(enum timeform): New enum.
(decode_time_components): New arg FORM. All callers changed.
RESULT and DRESULT are now mutually exclusive; no callers need
to change because of this.
(decode_time_components, lisp_time_struct)
(lisp_seconds_argument, time_arith, make_lisp_time, Ffloat_time)
(Fencode_time):
Add support for (TICKS . HZ) form.
(DECODE_SECS_ONLY): New constant.
(lisp_time_struct): 2nd arg is now enum timeform, not int.
All callers changed.
(check_tm_member): Support bignums.m
(Fencode_time): Add new two-arg functionality.
* src/systime.h (struct lisp_time): Now ticks+hz rather than
hi+lo+us+ps, since ticks+hz does not lose info.
* test/src/systime-tests.el (time-equal-p-nil-nil):
New test.
2018-10-03 09:10:01 -07:00
|
|
|
|
(setf (timer--high-seconds timer) (nth 0 lt))
|
|
|
|
|
(setf (timer--low-seconds timer) (nth 1 lt))
|
|
|
|
|
(setf (timer--usecs timer) (nth 2 lt))
|
|
|
|
|
(setf (timer--psecs timer) (nth 3 lt))
|
2013-08-12 22:30:52 -04:00
|
|
|
|
time))
|
|
|
|
|
|
2008-04-03 03:43:18 +00:00
|
|
|
|
;; Pseudo field `time'.
|
|
|
|
|
(defun timer--time (timer)
|
2013-08-12 22:30:52 -04:00
|
|
|
|
(declare (gv-setter timer--time-setter))
|
2008-04-03 03:43:18 +00:00
|
|
|
|
(list (timer--high-seconds timer)
|
|
|
|
|
(timer--low-seconds timer)
|
2012-06-22 14:17:42 -07:00
|
|
|
|
(timer--usecs timer)
|
|
|
|
|
(timer--psecs timer)))
|
2008-04-03 03:43:18 +00:00
|
|
|
|
|
2003-05-30 23:31:15 +00:00
|
|
|
|
(defun timer-set-time (timer time &optional delta)
|
|
|
|
|
"Set the trigger time of TIMER to TIME.
|
Avoid some double-rounding of Lisp timestamps
Also, simplify some time-related Lisp timestamp code
while we’re in the neighborhood.
* lisp/battery.el (battery-linux-proc-acpi)
(battery-linux-sysfs, battery-upower, battery-bsd-apm):
* lisp/calendar/timeclock.el (timeclock-seconds-to-string)
(timeclock-log, timeclock-last-period)
(timeclock-entry-length, timeclock-entry-list-span)
(timeclock-find-discrep, timeclock-generate-report):
* lisp/cedet/ede/detect.el (ede-detect-qtest):
* lisp/completion.el (cmpl-hours-since-origin):
* lisp/ecomplete.el (ecomplete-decay-1):
* lisp/emacs-lisp/ert.el (ert--results-update-stats-display)
(ert--results-update-stats-display-maybe):
* lisp/emacs-lisp/timer-list.el (list-timers):
* lisp/emacs-lisp/timer.el (timer-until)
(timer-event-handler):
* lisp/erc/erc-backend.el (erc-server-send-ping)
(erc-server-send-queue, erc-handle-parsed-server-response)
(erc-handle-unknown-server-response):
* lisp/erc/erc-track.el (erc-buffer-visible):
* lisp/erc/erc.el (erc-lurker-cleanup, erc-lurker-p)
(erc-cmd-PING, erc-send-current-line):
* lisp/eshell/em-pred.el (eshell-pred-file-time):
* lisp/eshell/em-unix.el (eshell-show-elapsed-time):
* lisp/gnus/gnus-icalendar.el (gnus-icalendar-event:org-timestamp):
* lisp/gnus/gnus-int.el (gnus-backend-trace):
* lisp/gnus/gnus-sum.el (gnus-user-date):
* lisp/gnus/mail-source.el (mail-source-delete-crash-box):
* lisp/gnus/nnmaildir.el (nnmaildir--scan):
* lisp/ibuf-ext.el (ibuffer-mark-old-buffers):
* lisp/gnus/nnmaildir.el (nnmaildir--scan):
* lisp/mouse.el (mouse--down-1-maybe-follows-link)
(mouse--click-1-maybe-follows-link):
* lisp/mpc.el (mpc--faster-toggle):
* lisp/net/rcirc.el (rcirc-handler-ctcp-KEEPALIVE)
(rcirc-sentinel):
* lisp/net/tramp-cache.el (tramp-get-file-property):
* lisp/net/tramp-sh.el (tramp-sh-handle-file-newer-than-file-p)
(tramp-maybe-open-connection):
* lisp/net/tramp-smb.el (tramp-smb-maybe-open-connection):
* lisp/org/org-clock.el (org-clock-resolve):
(org-resolve-clocks, org-clock-in, org-clock-out, org-clock-sum):
* lisp/org/org-timer.el (org-timer-start)
(org-timer-pause-or-continue, org-timer-seconds):
* lisp/org/org.el (org-evaluate-time-range):
* lisp/org/ox-publish.el (org-publish-cache-ctime-of-src):
* lisp/pixel-scroll.el (pixel-scroll-in-rush-p):
* lisp/play/hanoi.el (hanoi-move-ring):
* lisp/proced.el (proced-format-time):
* lisp/progmodes/cpp.el (cpp-progress-message):
* lisp/progmodes/flymake.el (flymake--handle-report):
* lisp/progmodes/js.el (js--wait-for-matching-output):
* lisp/subr.el (progress-reporter-do-update):
* lisp/term/xterm.el (xterm--read-event-for-query):
* lisp/time.el (display-time-update, emacs-uptime):
* lisp/tooltip.el (tooltip-delay):
* lisp/url/url-cookie.el (url-cookie-parse-file-netscape):
* lisp/url/url-queue.el (url-queue-prune-old-entries):
* lisp/url/url.el (url-retrieve-synchronously):
* lisp/xt-mouse.el (xterm-mouse-event):
Avoid double-rounding of time-related values. Simplify.
* lisp/calendar/icalendar.el (icalendar--decode-isodatetime):
When hoping for the best (unlikely), use a better decoded time.
(icalendar--convert-sexp-to-ical): Avoid unnecessary encode-time.
* lisp/calendar/timeclock.el (timeclock-when-to-leave):
* lisp/cedet/ede/detect.el (ede-detect-qtest):
* lisp/desktop.el (desktop-create-buffer):
* lisp/emacs-lisp/benchmark.el (benchmark-elapse):
* lisp/gnus/gnus-art.el (article-lapsed-string):
* lisp/gnus/gnus-group.el (gnus-group-timestamp-delta):
* lisp/gnus/nnmail.el (nnmail-expired-article-p):
* lisp/gnus/nnmaildir.el (nnmaildir-request-expire-articles):
* lisp/nxml/rng-maint.el (rng-time-function):
* lisp/org/org-clock.el (org-clock-get-clocked-time)
(org-clock-resolve, org-resolve-clocks, org-resolve-clocks-if-idle):
* lisp/org/org-habit.el (org-habit-insert-consistency-graphs):
* lisp/progmodes/vhdl-mode.el (vhdl-update-progress-info)
(vhdl-fix-case-region-1):
Use time-since instead of open-coding most of it.
* lisp/erc/erc-dcc.el (erc-dcc-get-sentinel):
* lisp/erc/erc.el (erc-string-to-emacs-time, erc-time-gt):
Now obsolete. All uses changed.
(erc-time-diff): Accept all Lisp time values.
All uses changed.
* lisp/gnus/gnus-demon.el (gnus-demon-idle-since):
* lisp/gnus/gnus-score.el (gnus-score-headers):
* lisp/gnus/nneething.el (nneething-make-head):
* lisp/gnus/nnheader.el (nnheader-message-maybe):
* lisp/gnus/nnimap.el (nnimap-keepalive):
* lisp/image.el (image-animate-timeout):
* lisp/mail/feedmail.el (feedmail-rfc822-date):
* lisp/net/imap.el (imap-wait-for-tag):
* lisp/net/newst-backend.el (newsticker--image-get):
* lisp/net/rcirc.el (rcirc-handler-317, rcirc-handler-333):
* lisp/obsolete/xesam.el (xesam-refresh-entry):
* lisp/org/org-agenda.el (org-agenda-show-clocking-issues)
(org-agenda-check-clock-gap, org-agenda-to-appt):
* lisp/org/org-capture.el (org-capture-set-target-location):
* lisp/org/org-clock.el (org-clock-resolve-clock)
(org-clocktable-steps):
* lisp/org/org-colview.el (org-columns-edit-value)
(org-columns, org-agenda-columns):
* lisp/org/org-duration.el (org-duration-from-minutes):
* lisp/org/org-element.el (org-element-cache-sync-duration)
(org-element-cache-sync-break)
(org-element--cache-interrupt-p, org-element--cache-sync):
* lisp/org/org-habit.el (org-habit-get-faces)
* lisp/org/org-indent.el (org-indent-add-properties):
* lisp/org/org-table.el (org-table-sum):
* lisp/org/org-timer.el (org-timer-show-remaining-time)
(org-timer-set-timer):
* lisp/org/org.el (org-babel-load-file, org-today)
(org-auto-repeat-maybe, org-2ft, org-time-stamp)
(org-read-date-analyze, org-time-stamp-to-now)
(org-small-year-to-year, org-goto-calendar):
* lisp/org/ox.el (org-export-insert-default-template):
* lisp/ses.el (ses--time-check):
* lisp/type-break.el (type-break-time-warning)
(type-break-statistics, type-break-demo-boring):
* lisp/url/url-cache.el (url-cache-expired)
(url-cache-prune-cache):
* lisp/vc/vc-git.el (vc-git-stash-snapshot):
* lisp/erc/erc-match.el (erc-log-matches-come-back):
Simplify.
2019-02-22 18:32:31 -08:00
|
|
|
|
TIME must be a Lisp time value.
|
2003-05-30 23:31:15 +00:00
|
|
|
|
If optional third argument DELTA is a positive number, make the timer
|
|
|
|
|
fire repeatedly that many seconds apart."
|
Provide generalized variables in core Elisp.
* lisp/emacs-lisp/gv.el: New file.
* lisp/subr.el (push, pop): Extend to generalized variables.
* lisp/loadup.el (macroexp): Unload if preloaded and uncompiled.
* lisp/emacs-lisp/cl-lib.el (cl-pop, cl-push, cl--set-nthcdr): Remove.
* lisp/emacs-lisp/cl-macs.el: Require gv. Use gv-define-setter,
gv-define-simple-setter, and gv-define-expander.
Remove setf-methods defined in gv. Rename cl-setf -> setf.
(cl-setf, cl-do-pop, cl-get-setf-method): Remove.
(cl-letf, cl-letf*, cl-define-modify-macro, cl-defsetf)
(cl-define-setf-expander, cl-struct-setf-expander): Move to cl.el.
(cl-remf, cl-shiftf, cl-rotatef, cl-callf, cl-callf2): Rewrite with
gv-letplace.
(cl-defstruct): Don't define setf-method any more.
* lisp/emacs-lisp/cl.el (flet): Don't autoload.
(cl--letf, letf, cl--letf*, letf*, cl--gv-adapt)
(define-setf-expander, defsetf, define-modify-macro)
(cl-struct-setf-expander): Move from cl-lib.el.
* lisp/emacs-lisp/syntax.el:
* lisp/emacs-lisp/ewoc.el:
* lisp/emacs-lisp/smie.el:
* lisp/emacs-lisp/cconv.el:
* lisp/emacs-lisp/timer.el: Rename cl-setf -> setf, cl-push -> push.
(timer--time): Use gv-define-simple-setter.
* lisp/emacs-lisp/macroexp.el (macroexp-let2): Rename from macroexp-let²
to avoid coding-system problems in subr.el. Adjust all users.
(macroexp--maxsize, macroexp-small-p): New functions.
* lisp/emacs-lisp/bytecomp.el (byte-compile-file): Don't use cl-letf.
* lisp/scroll-bar.el (scroll-bar-mode):
* lisp/simple.el (auto-fill-mode, overwrite-mode, binary-overwrite-mode)
(normal-erase-is-backspace-mode): Don't use the `eq' place.
* lisp/winner.el (winner-configuration, winner-make-point-alist)
(winner-set-conf, winner-get-point, winner-set): Don't abuse letf.
* lisp/files.el (locate-file-completion-table): Avoid list*.
Fixes: debbugs:11657
2012-06-22 09:42:38 -04:00
|
|
|
|
(setf (timer--time timer) time)
|
|
|
|
|
(setf (timer--repeat-delay timer) (and (numberp delta) (> delta 0) delta))
|
2003-05-30 23:31:15 +00:00
|
|
|
|
timer)
|
|
|
|
|
|
|
|
|
|
(defun timer-set-idle-time (timer secs &optional repeat)
|
2013-04-10 09:31:35 -04:00
|
|
|
|
;; FIXME: Merge with timer-set-time.
|
2003-05-30 23:31:15 +00:00
|
|
|
|
"Set the trigger idle time of TIMER to SECS.
|
2006-08-24 23:40:00 +00:00
|
|
|
|
SECS may be an integer, floating point number, or the internal
|
2012-06-22 14:17:42 -07:00
|
|
|
|
time format returned by, e.g., `current-idle-time'.
|
2003-05-30 23:31:15 +00:00
|
|
|
|
If optional third argument REPEAT is non-nil, make the timer
|
|
|
|
|
fire each time Emacs is idle for that many seconds."
|
Simplify use of encode-time
Most uses of (apply #'encode-time foo) can now be replaced
with (encode-time foo). Make similar simplifications.
* lisp/calendar/time-date.el (date-to-time):
* lisp/calendar/timeclock.el (timeclock-when-to-leave)
(timeclock-day-base, timeclock-generate-report):
* lisp/emacs-lisp/timer.el (timer-set-idle-time):
* lisp/eshell/esh-util.el (eshell-parse-ange-ls):
* lisp/gnus/gnus-art.el (article-make-date-line):
* lisp/gnus/gnus-delay.el (gnus-delay-article)
(gnus-delay-send-queue):
* lisp/gnus/gnus-icalendar.el (gnus-icalendar-event--decode-datefield):
* lisp/gnus/gnus-logic.el (gnus-advanced-date):
* lisp/gnus/message.el (message-make-expires-date):
* lisp/gnus/nndiary.el (nndiary-compute-reminders):
* lisp/mail/ietf-drums.el (ietf-drums-parse-date):
* lisp/net/tramp-adb.el (tramp-adb-ls-output-time-less-p):
* lisp/org/org-agenda.el (org-agenda-get-timestamps)
(org-agenda-get-progress, org-agenda-show-clocking-issues):
* lisp/org/org-capture.el (org-capture-set-target-location):
* lisp/org/org-clock.el (org-clock-get-sum-start, org-clock-sum)
(org-clocktable-steps):
* lisp/org/org-colview.el (org-colview-construct-allowed-dates)
* lisp/org/org-macro.el (org-macro--vc-modified-time):
* lisp/org/org-table.el (org-table-eval-formula):
* lisp/org/org.el (org-current-time, org-store-link)
(org-time-today, org-read-date, org-read-date-display)
(org-display-custom-time, org-time-string-to-time)
(org-timestamp-change, org-timestamp--to-internal-time):
* lisp/url/url-dav.el (url-dav-process-date-property):
* lisp/vc/vc-cvs.el (vc-cvs-annotate-current-time)
(vc-cvs-parse-entry):
Simplify use of encode-time.
* lisp/org/org-clock.el (org-clock-get-clocked-time):
(org-clock-resolve, org-resolve-clocks, org_clock_out)
(org-clock-update-time-maybe):
Avoid some rounding problems with encode-time and float-time.
* lisp/org/org-clock.el (org-clock-in, org-clock-update-time-maybe):
* lisp/org/org-colview.el (org-columns--age-to-minutes):
* lisp/org/org.el (org-get-scheduled-time, org-get-deadline-time)
(org-add-planning-info, org-2ft, org-time-string-to-absolute)
(org-closest-date):
Use org-time-string-to-time instead of doing it by hand with
encode-time.
* lisp/org/org.el (org-current-time): Simplify rounding.
(org-read-date): Avoid extra trip through encode-time.
2019-02-10 20:25:22 -08:00
|
|
|
|
(setf (timer--time timer) secs)
|
Provide generalized variables in core Elisp.
* lisp/emacs-lisp/gv.el: New file.
* lisp/subr.el (push, pop): Extend to generalized variables.
* lisp/loadup.el (macroexp): Unload if preloaded and uncompiled.
* lisp/emacs-lisp/cl-lib.el (cl-pop, cl-push, cl--set-nthcdr): Remove.
* lisp/emacs-lisp/cl-macs.el: Require gv. Use gv-define-setter,
gv-define-simple-setter, and gv-define-expander.
Remove setf-methods defined in gv. Rename cl-setf -> setf.
(cl-setf, cl-do-pop, cl-get-setf-method): Remove.
(cl-letf, cl-letf*, cl-define-modify-macro, cl-defsetf)
(cl-define-setf-expander, cl-struct-setf-expander): Move to cl.el.
(cl-remf, cl-shiftf, cl-rotatef, cl-callf, cl-callf2): Rewrite with
gv-letplace.
(cl-defstruct): Don't define setf-method any more.
* lisp/emacs-lisp/cl.el (flet): Don't autoload.
(cl--letf, letf, cl--letf*, letf*, cl--gv-adapt)
(define-setf-expander, defsetf, define-modify-macro)
(cl-struct-setf-expander): Move from cl-lib.el.
* lisp/emacs-lisp/syntax.el:
* lisp/emacs-lisp/ewoc.el:
* lisp/emacs-lisp/smie.el:
* lisp/emacs-lisp/cconv.el:
* lisp/emacs-lisp/timer.el: Rename cl-setf -> setf, cl-push -> push.
(timer--time): Use gv-define-simple-setter.
* lisp/emacs-lisp/macroexp.el (macroexp-let2): Rename from macroexp-let²
to avoid coding-system problems in subr.el. Adjust all users.
(macroexp--maxsize, macroexp-small-p): New functions.
* lisp/emacs-lisp/bytecomp.el (byte-compile-file): Don't use cl-letf.
* lisp/scroll-bar.el (scroll-bar-mode):
* lisp/simple.el (auto-fill-mode, overwrite-mode, binary-overwrite-mode)
(normal-erase-is-backspace-mode): Don't use the `eq' place.
* lisp/winner.el (winner-configuration, winner-make-point-alist)
(winner-set-conf, winner-get-point, winner-set): Don't abuse letf.
* lisp/files.el (locate-file-completion-table): Avoid list*.
Fixes: debbugs:11657
2012-06-22 09:42:38 -04:00
|
|
|
|
(setf (timer--repeat-delay timer) repeat)
|
2003-05-30 23:31:15 +00:00
|
|
|
|
timer)
|
|
|
|
|
|
|
|
|
|
(defun timer-next-integral-multiple-of-time (time secs)
|
|
|
|
|
"Yield the next value after TIME that is an integral multiple of SECS.
|
|
|
|
|
More precisely, the next value, after TIME, that is an integral multiple
|
|
|
|
|
of SECS seconds since the epoch. SECS may be a fraction."
|
New function time-convert
This replaces the awkward reuse of encode-time to both convert
calendrical timestamps to Lisp timestamps, and to convert Lisp
timestamps to other forms. Now, encode-time does just the
former and the new function does just the latter.
The new function builds on a suggestion by Lars Ingebrigtsen in:
https://lists.gnu.org/r/emacs-devel/2019-07/msg00801.html
and refined by Stefan Monnier in:
https://lists.gnu.org/r/emacs-devel/2019-07/msg00803.html
* doc/lispref/os.texi (Time of Day, Time Conversion):
* doc/misc/emacs-mime.texi (time-date):
* etc/NEWS: Update documentation.
* lisp/calendar/cal-dst.el (calendar-next-time-zone-transition):
* lisp/calendar/time-date.el (seconds-to-time, days-to-time):
* lisp/calendar/timeclock.el (timeclock-seconds-to-time):
* lisp/cedet/ede/detect.el (ede-detect-qtest):
* lisp/completion.el (cmpl-hours-since-origin):
* lisp/ecomplete.el (ecomplete-add-item):
* lisp/emacs-lisp/cl-extra.el (cl--random-time):
* lisp/emacs-lisp/timer.el (timer--time-setter)
(timer-next-integral-multiple-of-time):
* lisp/find-lisp.el (find-lisp-format-time):
* lisp/gnus/gnus-diary.el (gnus-user-format-function-d):
* lisp/gnus/gnus-group.el (gnus-group-set-timestamp):
* lisp/gnus/gnus-icalendar.el (gnus-icalendar-show-org-agenda):
* lisp/gnus/nnrss.el (nnrss-normalize-date):
* lisp/gnus/nnspool.el (nnspool-request-newgroups):
* lisp/net/ntlm.el (ntlm-compute-timestamp):
* lisp/net/pop3.el (pop3-uidl-dele):
* lisp/obsolete/vc-arch.el (vc-arch-add-tagline):
* lisp/org/org-clock.el (org-clock-get-clocked-time)
(org-clock-resolve, org-resolve-clocks, org-clock-in)
(org-clock-out, org-clock-sum):
* lisp/org/org-id.el (org-id-uuid, org-id-time-to-b36):
* lisp/org/ox-publish.el (org-publish-cache-ctime-of-src):
* lisp/proced.el (proced-format-time):
* lisp/progmodes/cc-cmds.el (c-progress-init)
(c-progress-update):
* lisp/progmodes/cperl-mode.el (cperl-time-fontification):
* lisp/progmodes/flymake.el (flymake--schedule-timer-maybe):
* lisp/progmodes/vhdl-mode.el (vhdl-update-progress-info)
(vhdl-fix-case-region-1):
* lisp/tar-mode.el (tar-octal-time):
* lisp/time.el (emacs-uptime):
* lisp/url/url-auth.el (url-digest-auth-make-cnonce):
* lisp/url/url-util.el (url-lazy-message):
* lisp/vc/vc-cvs.el (vc-cvs-parse-entry):
* lisp/vc/vc-hg.el (vc-hg-state-fast):
* lisp/xt-mouse.el (xterm-mouse-event):
* test/lisp/emacs-lisp/timer-tests.el:
(timer-next-integral-multiple-of-time-2):
Use time-convert, not encode-time.
* lisp/calendar/icalendar.el (icalendar--decode-isodatetime):
Don’t use now-removed FORM argument for encode-time.
It wasn’t crucial anyway.
* lisp/emacs-lisp/byte-opt.el (side-effect-free-fns): Add time-convert.
* lisp/emacs-lisp/elint.el (elint-unknown-builtin-args):
Update encode-time signature to match current arg set.
* lisp/emacs-lisp/timer.el (timer-next-integral-multiple-of-time):
Use timer-convert with t rather than doing it by hand.
* src/timefns.c (time_hz_ticks, time_form_stamp, lisp_time_form_stamp):
Remove; no longer needed.
(decode_lisp_time): Rturn the form instead of having a *PFORM arg.
All uses changed.
(time_arith): Just return TICKS if HZ is 1.
(Fencode_time): Remove argument FORM. All callers changed.
Do not attempt to encode time values; just encode
decoded (calendrical) times.
Unless CURRENT_TIME_LIST, just return VALUE since HZ is 1.
(Ftime_convert): New function, which does the time value
conversion that bleeding-edge encode-time formerly did.
Return TIME if it is easy to see that it is already
of the correct form.
(Fcurrent_time): Mention in doc that the form is planned to change.
* test/src/timefns-tests.el (decode-then-encode-time):
Don’t use (encode-time nil).
2019-08-05 17:38:52 -07:00
|
|
|
|
(let* ((ticks-hz (time-convert time t))
|
2018-10-22 19:31:15 -07:00
|
|
|
|
(ticks (car ticks-hz))
|
New (TICKS . HZ) timestamp format
This follows on a suggestion by Stefan Monnier in:
https://lists.gnu.org/r/emacs-devel/2018-08/msg00991.html
(Bug#32902).
* doc/lispref/buffers.texi (Modification Time):
* doc/lispref/os.texi (Processor Run Time, Time Calculations)
* doc/lispref/processes.texi (System Processes):
* doc/lispref/text.texi (Undo):
Let the "Time of Day" section cover timestamp format details.
* doc/lispref/os.texi (Time of Day):
Say that timestamp internal format should not be assumed.
Document new (ticks . hz) format. Omit mention of seconds-to-time
since it is now just an alias for encode-time.
(Time Conversion): Document encode-time extension.
* etc/NEWS: Mention changes.
* lisp/calendar/cal-dst.el (calendar-system-time-basis): Now const.
* lisp/calendar/cal-dst.el (calendar-absolute-from-time)
(calendar-time-from-absolute)
(calendar-next-time-zone-transition):
* lisp/emacs-lisp/timer.el (timer-next-integral-multiple-of-time):
Simplify by using bignums, (TICKS . HZ), and new encode-time.
* lisp/emacs-lisp/timer.el (timer-next-integral-multiple-of-time):
Simplify by using bignums and new encode-time.
* lisp/calendar/parse-time.el (parse-iso8601-time-string):
Handle DST more accurately, by using new encode-time.
* lisp/calendar/time-date.el (seconds-to-time):
* lisp/calendar/timeclock.el (timeclock-seconds-to-time):
Now just an alias for encode-time.
* lisp/calendar/time-date.el (days-to-time):
* lisp/emacs-lisp/timer.el (timer--time-setter):
* lisp/net/ntlm.el (ntlm-compute-timestamp):
* lisp/obsolete/vc-arch.el (vc-arch-add-tagline):
* lisp/org/org-id.el (org-id-uuid, org-id-time-to-b36):
* lisp/tar-mode (tar-octal-time):
Don't assume timestamps default to list form.
* lisp/tar-mode.el (tar-parse-octal-long-integer):
Now an obsolete alias for tar-parse-octal-integer.
* src/keyboard.c (decode_timer): Adjust to changes to
time decoding functions elsewhere.
* src/timefns.c: Include bignum.h, limits.h.
(FASTER_TIMEFNS): New macro.
(WARN_OBSOLETE_TIMESTAMPS, CURRENT_TIME_LIST)
(timespec_hz, trillion, ztrillion):
New constants.
(make_timeval): Use TIME_T_MAX instead of its definiens.
(check_time_validity, time_add, time_subtract):
Remove. All uses removed.
(disassemble_lisp_time): Remove; old code now folded into
decode_lisp_time. All callers changed.
(invalid_hz, s_ns_to_double, ticks_hz_list4, mpz_set_time)
(timespec_mpz, timespec_ticks, time_hz_ticks)
(lisp_time_hz_ticks, lisp_time_seconds)
(time_form_stamp, lisp_time_form_stamp, decode_ticks_hz)
(decode_lisp_time, mpz_time, list4_to_timespec):
New functions.
(decode_float_time, decode_time_components, lisp_to_timespec):
Adjust to new struct lisp_time, which does not lose
information like the old one did.
(enum timeform): New enum.
(decode_time_components): New arg FORM. All callers changed.
RESULT and DRESULT are now mutually exclusive; no callers need
to change because of this.
(decode_time_components, lisp_time_struct)
(lisp_seconds_argument, time_arith, make_lisp_time, Ffloat_time)
(Fencode_time):
Add support for (TICKS . HZ) form.
(DECODE_SECS_ONLY): New constant.
(lisp_time_struct): 2nd arg is now enum timeform, not int.
All callers changed.
(check_tm_member): Support bignums.m
(Fencode_time): Add new two-arg functionality.
* src/systime.h (struct lisp_time): Now ticks+hz rather than
hi+lo+us+ps, since ticks+hz does not lose info.
* test/src/systime-tests.el (time-equal-p-nil-nil):
New test.
2018-10-03 09:10:01 -07:00
|
|
|
|
(hz (cdr ticks-hz))
|
2018-10-22 19:31:15 -07:00
|
|
|
|
trunc-s-ticks)
|
|
|
|
|
(while (let ((s-ticks (* secs hz)))
|
|
|
|
|
(setq trunc-s-ticks (truncate s-ticks))
|
|
|
|
|
(/= s-ticks trunc-s-ticks))
|
|
|
|
|
(setq ticks (ash ticks 1))
|
|
|
|
|
(setq hz (ash hz 1)))
|
|
|
|
|
(let ((more-ticks (+ ticks trunc-s-ticks)))
|
2022-08-05 18:46:31 -04:00
|
|
|
|
(time-convert (cons (- more-ticks (% more-ticks trunc-s-ticks)) hz) t))))
|
2012-06-22 14:17:42 -07:00
|
|
|
|
|
|
|
|
|
(defun timer-relative-time (time secs &optional usecs psecs)
|
2021-09-27 23:56:55 +02:00
|
|
|
|
"Advance TIME by SECS seconds.
|
|
|
|
|
|
|
|
|
|
Optionally also advance it by USECS microseconds and PSECS
|
|
|
|
|
picoseconds.
|
|
|
|
|
|
|
|
|
|
SECS may be either an integer or a floating point number."
|
Improve time stamp handling, and be more consistent about it.
This implements a suggestion made in:
http://lists.gnu.org/archive/html/emacs-devel/2014-10/msg00587.html
Among other things, this means timer.el no longer needs to
autoload the time-date module.
* doc/lispref/os.texi (Time of Day, Time Conversion, Time Parsing)
(Processor Run Time, Time Calculations):
Document the new behavior, plus be clearer about the old behavior.
(Idle Timers): Take advantage of new functionality.
* etc/NEWS: Document the changes.
* lisp/allout-widgets.el (allout-elapsed-time-seconds): Doc fix.
* lisp/arc-mode.el (archive-ar-summarize):
* lisp/calendar/time-date.el (seconds-to-time, days-to-time, time-since):
* lisp/emacs-lisp/timer.el (timer-relative-time, timer-event-handler)
(run-at-time, with-timeout-suspend, with-timeout-unsuspend):
* lisp/net/tramp.el (tramp-time-less-p, tramp-time-subtract):
* lisp/proced.el (proced-time-lessp):
* lisp/timezone.el (timezone-time-from-absolute):
* lisp/type-break.el (type-break-schedule, type-break-time-sum):
Simplify by using new functionality.
* lisp/calendar/cal-dst.el (calendar-next-time-zone-transition):
Do not return time values in obsolete and undocumented (HI . LO)
format; use (HI LO) instead.
* lisp/calendar/time-date.el (with-decoded-time-value):
Treat 'nil' as current time. This is mostly for XEmacs.
(encode-time-value, with-decoded-time-value): Obsolete.
(time-add, time-subtract, time-less-p): Use no-op autoloads, for
XEmacs. Define only if XEmacs, as they're now C builtins in Emacs.
* lisp/ldefs-boot.el: Update to match new time-date.el
* lisp/proced.el: Do not require time-date.
* src/editfns.c (invalid_time): New function.
Use it instead of 'error ("Invalid time specification")'.
(time_add, time_subtract, time_arith, Ftime_add, Ftime_less_p)
(decode_float_time, lisp_to_timespec, lisp_time_struct):
New functions.
(make_time_tail, make_time): Remove. All uses changed to use
new functions or plain list4i.
(disassemble_lisp_time): Return effective length if successful.
Check that LOW is an integer, if it's combined with other components.
(decode_time_components): Decode into struct lisp_time, not
struct timespec, so that we can support a wide set of times
regardless of whether time_t is signed. Decode plain numbers
as seconds since the Epoch, and nil as the current time.
(lisp_time_argument, lisp_seconds_argument, Ffloat_time):
Reimplement in terms of new functions.
(Fencode_time): Just use list2i.
(syms_of_editfns): Add time-add, time-subtract, time-less-p.
* src/keyboard.c (decode_timer): Don't allow the new formats (floating
point or nil) in timers.
* src/systime.h (LO_TIME_BITS): New constant. Use it everywhere in
place of the magic number '16'.
(struct lisp_time): New type.
(decode_time_components): Use it.
(lisp_to_timespec): New decl.
2014-11-16 20:38:15 -08:00
|
|
|
|
(let ((delta secs))
|
2012-06-22 14:17:42 -07:00
|
|
|
|
(if (or usecs psecs)
|
|
|
|
|
(setq delta (time-add delta (list 0 0 (or usecs 0) (or psecs 0)))))
|
2011-06-30 18:27:40 -07:00
|
|
|
|
(time-add time delta)))
|
2003-05-30 23:31:15 +00:00
|
|
|
|
|
2008-04-03 03:43:18 +00:00
|
|
|
|
(defun timer--time-less-p (t1 t2)
|
|
|
|
|
"Say whether time value T1 is less than time value T2."
|
2011-07-03 23:25:23 -07:00
|
|
|
|
(time-less-p (timer--time t1) (timer--time t2)))
|
2008-04-03 03:43:18 +00:00
|
|
|
|
|
2012-06-22 14:17:42 -07:00
|
|
|
|
(defun timer-inc-time (timer secs &optional usecs psecs)
|
2021-09-27 23:56:55 +02:00
|
|
|
|
"Increment the time set in TIMER by SECS seconds.
|
|
|
|
|
|
|
|
|
|
Optionally also increment it by USECS microseconds, and PSECS
|
|
|
|
|
picoseconds. If USECS or PSECS are omitted, they are treated as
|
|
|
|
|
zero.
|
|
|
|
|
|
|
|
|
|
SECS may be a fraction."
|
Provide generalized variables in core Elisp.
* lisp/emacs-lisp/gv.el: New file.
* lisp/subr.el (push, pop): Extend to generalized variables.
* lisp/loadup.el (macroexp): Unload if preloaded and uncompiled.
* lisp/emacs-lisp/cl-lib.el (cl-pop, cl-push, cl--set-nthcdr): Remove.
* lisp/emacs-lisp/cl-macs.el: Require gv. Use gv-define-setter,
gv-define-simple-setter, and gv-define-expander.
Remove setf-methods defined in gv. Rename cl-setf -> setf.
(cl-setf, cl-do-pop, cl-get-setf-method): Remove.
(cl-letf, cl-letf*, cl-define-modify-macro, cl-defsetf)
(cl-define-setf-expander, cl-struct-setf-expander): Move to cl.el.
(cl-remf, cl-shiftf, cl-rotatef, cl-callf, cl-callf2): Rewrite with
gv-letplace.
(cl-defstruct): Don't define setf-method any more.
* lisp/emacs-lisp/cl.el (flet): Don't autoload.
(cl--letf, letf, cl--letf*, letf*, cl--gv-adapt)
(define-setf-expander, defsetf, define-modify-macro)
(cl-struct-setf-expander): Move from cl-lib.el.
* lisp/emacs-lisp/syntax.el:
* lisp/emacs-lisp/ewoc.el:
* lisp/emacs-lisp/smie.el:
* lisp/emacs-lisp/cconv.el:
* lisp/emacs-lisp/timer.el: Rename cl-setf -> setf, cl-push -> push.
(timer--time): Use gv-define-simple-setter.
* lisp/emacs-lisp/macroexp.el (macroexp-let2): Rename from macroexp-let²
to avoid coding-system problems in subr.el. Adjust all users.
(macroexp--maxsize, macroexp-small-p): New functions.
* lisp/emacs-lisp/bytecomp.el (byte-compile-file): Don't use cl-letf.
* lisp/scroll-bar.el (scroll-bar-mode):
* lisp/simple.el (auto-fill-mode, overwrite-mode, binary-overwrite-mode)
(normal-erase-is-backspace-mode): Don't use the `eq' place.
* lisp/winner.el (winner-configuration, winner-make-point-alist)
(winner-set-conf, winner-get-point, winner-set): Don't abuse letf.
* lisp/files.el (locate-file-completion-table): Avoid list*.
Fixes: debbugs:11657
2012-06-22 09:42:38 -04:00
|
|
|
|
(setf (timer--time timer)
|
2012-06-22 14:17:42 -07:00
|
|
|
|
(timer-relative-time (timer--time timer) secs usecs psecs)))
|
2003-05-30 23:31:15 +00:00
|
|
|
|
|
|
|
|
|
(defun timer-set-function (timer function &optional args)
|
|
|
|
|
"Make TIMER call FUNCTION with optional ARGS when triggering."
|
2013-04-10 09:31:35 -04:00
|
|
|
|
(timer--check timer)
|
Provide generalized variables in core Elisp.
* lisp/emacs-lisp/gv.el: New file.
* lisp/subr.el (push, pop): Extend to generalized variables.
* lisp/loadup.el (macroexp): Unload if preloaded and uncompiled.
* lisp/emacs-lisp/cl-lib.el (cl-pop, cl-push, cl--set-nthcdr): Remove.
* lisp/emacs-lisp/cl-macs.el: Require gv. Use gv-define-setter,
gv-define-simple-setter, and gv-define-expander.
Remove setf-methods defined in gv. Rename cl-setf -> setf.
(cl-setf, cl-do-pop, cl-get-setf-method): Remove.
(cl-letf, cl-letf*, cl-define-modify-macro, cl-defsetf)
(cl-define-setf-expander, cl-struct-setf-expander): Move to cl.el.
(cl-remf, cl-shiftf, cl-rotatef, cl-callf, cl-callf2): Rewrite with
gv-letplace.
(cl-defstruct): Don't define setf-method any more.
* lisp/emacs-lisp/cl.el (flet): Don't autoload.
(cl--letf, letf, cl--letf*, letf*, cl--gv-adapt)
(define-setf-expander, defsetf, define-modify-macro)
(cl-struct-setf-expander): Move from cl-lib.el.
* lisp/emacs-lisp/syntax.el:
* lisp/emacs-lisp/ewoc.el:
* lisp/emacs-lisp/smie.el:
* lisp/emacs-lisp/cconv.el:
* lisp/emacs-lisp/timer.el: Rename cl-setf -> setf, cl-push -> push.
(timer--time): Use gv-define-simple-setter.
* lisp/emacs-lisp/macroexp.el (macroexp-let2): Rename from macroexp-let²
to avoid coding-system problems in subr.el. Adjust all users.
(macroexp--maxsize, macroexp-small-p): New functions.
* lisp/emacs-lisp/bytecomp.el (byte-compile-file): Don't use cl-letf.
* lisp/scroll-bar.el (scroll-bar-mode):
* lisp/simple.el (auto-fill-mode, overwrite-mode, binary-overwrite-mode)
(normal-erase-is-backspace-mode): Don't use the `eq' place.
* lisp/winner.el (winner-configuration, winner-make-point-alist)
(winner-set-conf, winner-get-point, winner-set): Don't abuse letf.
* lisp/files.el (locate-file-completion-table): Avoid list*.
Fixes: debbugs:11657
2012-06-22 09:42:38 -04:00
|
|
|
|
(setf (timer--function timer) function)
|
|
|
|
|
(setf (timer--args timer) args)
|
2003-05-30 23:31:15 +00:00
|
|
|
|
timer)
|
|
|
|
|
|
2008-04-03 03:43:18 +00:00
|
|
|
|
(defun timer--activate (timer &optional triggered-p reuse-cell idle)
|
2022-08-05 10:38:59 -04:00
|
|
|
|
(let ((timers (if idle timer-idle-list timer-list))
|
|
|
|
|
last)
|
|
|
|
|
(cond
|
|
|
|
|
((not (and (timerp timer)
|
|
|
|
|
(integerp (timer--high-seconds timer))
|
|
|
|
|
(integerp (timer--low-seconds timer))
|
|
|
|
|
(integerp (timer--usecs timer))
|
|
|
|
|
(integerp (timer--psecs timer))
|
|
|
|
|
(timer--function timer)))
|
|
|
|
|
(error "Invalid or uninitialized timer"))
|
|
|
|
|
;; FIXME: This is not reliable because `idle-delay' is only set late,
|
|
|
|
|
;; by `timer-activate-when-idle' :-(
|
|
|
|
|
;;((not (eq (not idle)
|
|
|
|
|
;; (not (timer--idle-delay timer))))
|
|
|
|
|
;; (error "idle arg %S out of sync with idle-delay field of timer: %S"
|
|
|
|
|
;; idle timer))
|
|
|
|
|
((memq timer timers)
|
|
|
|
|
(error "Timer already activated"))
|
|
|
|
|
(t
|
|
|
|
|
;; Skip all timers to trigger before the new one.
|
|
|
|
|
(while (and timers (timer--time-less-p (car timers) timer))
|
|
|
|
|
(setq last timers
|
|
|
|
|
timers (cdr timers)))
|
|
|
|
|
(if reuse-cell
|
|
|
|
|
(progn
|
|
|
|
|
(setcar reuse-cell timer)
|
|
|
|
|
(setcdr reuse-cell timers))
|
|
|
|
|
(setq reuse-cell (cons timer timers)))
|
|
|
|
|
;; Insert new timer after last which possibly means in front of queue.
|
|
|
|
|
(setf (cond (last (cdr last))
|
|
|
|
|
(idle timer-idle-list)
|
|
|
|
|
(t timer-list))
|
|
|
|
|
reuse-cell)
|
|
|
|
|
(setf (timer--triggered timer) triggered-p)
|
|
|
|
|
(setf (timer--idle-delay timer) idle)
|
|
|
|
|
nil))))
|
2003-05-30 23:31:15 +00:00
|
|
|
|
|
2011-06-04 18:46:26 -04:00
|
|
|
|
(defun timer-activate (timer &optional triggered-p reuse-cell)
|
|
|
|
|
"Insert TIMER into `timer-list'.
|
|
|
|
|
If TRIGGERED-P is t, make TIMER inactive (put it on the list, but
|
|
|
|
|
mark it as already triggered). To remove it, use `cancel-timer'.
|
2008-04-03 03:43:18 +00:00
|
|
|
|
|
2011-06-04 18:46:26 -04:00
|
|
|
|
REUSE-CELL, if non-nil, is a cons cell to reuse when inserting
|
|
|
|
|
TIMER into `timer-list' (usually a cell removed from that list by
|
|
|
|
|
`cancel-timer-internal'; using this reduces consing for repeat
|
|
|
|
|
timers). If nil, allocate a new cell."
|
2008-04-03 03:43:18 +00:00
|
|
|
|
(timer--activate timer triggered-p reuse-cell nil))
|
|
|
|
|
|
2005-10-29 19:47:23 +00:00
|
|
|
|
(defun timer-activate-when-idle (timer &optional dont-wait reuse-cell)
|
2011-06-04 18:46:26 -04:00
|
|
|
|
"Insert TIMER into `timer-idle-list'.
|
|
|
|
|
This arranges to activate TIMER whenever Emacs is next idle.
|
|
|
|
|
If optional argument DONT-WAIT is non-nil, set TIMER to activate
|
2015-09-17 16:08:20 -07:00
|
|
|
|
immediately \(see below), or at the right time, if Emacs is
|
2012-09-22 16:16:03 +03:00
|
|
|
|
already idle.
|
2011-06-04 18:46:26 -04:00
|
|
|
|
|
|
|
|
|
REUSE-CELL, if non-nil, is a cons cell to reuse when inserting
|
|
|
|
|
TIMER into `timer-idle-list' (usually a cell removed from that
|
|
|
|
|
list by `cancel-timer-internal'; using this reduces consing for
|
2012-09-22 16:16:03 +03:00
|
|
|
|
repeat timers). If nil, allocate a new cell.
|
|
|
|
|
|
|
|
|
|
Using non-nil DONT-WAIT is not recommended when activating an
|
|
|
|
|
idle timer from an idle timer handler, if the timer being
|
|
|
|
|
activated has an idleness time that is smaller or equal to
|
|
|
|
|
the time of the current timer. That's because the activated
|
|
|
|
|
timer will fire right away."
|
2008-04-03 03:43:18 +00:00
|
|
|
|
(timer--activate timer (not dont-wait) reuse-cell 'idle))
|
2003-05-30 23:31:15 +00:00
|
|
|
|
|
2022-08-05 10:38:59 -04:00
|
|
|
|
(defalias 'disable-timeout #'cancel-timer)
|
2008-03-14 17:42:18 +00:00
|
|
|
|
|
2003-05-30 23:31:15 +00:00
|
|
|
|
(defun cancel-timer (timer)
|
|
|
|
|
"Remove TIMER from the list of active timers."
|
2013-04-10 09:31:35 -04:00
|
|
|
|
(timer--check timer)
|
2003-05-30 23:31:15 +00:00
|
|
|
|
(setq timer-list (delq timer timer-list))
|
|
|
|
|
(setq timer-idle-list (delq timer timer-idle-list))
|
|
|
|
|
nil)
|
|
|
|
|
|
2005-10-29 19:47:23 +00:00
|
|
|
|
(defun cancel-timer-internal (timer)
|
2006-09-08 12:00:40 +00:00
|
|
|
|
"Remove TIMER from the list of active timers or idle timers.
|
|
|
|
|
Only to be used in this file. It returns the cons cell
|
|
|
|
|
that was removed from the timer list."
|
2005-10-29 19:47:23 +00:00
|
|
|
|
(let ((cell1 (memq timer timer-list))
|
|
|
|
|
(cell2 (memq timer timer-idle-list)))
|
|
|
|
|
(if cell1
|
|
|
|
|
(setq timer-list (delq timer timer-list)))
|
|
|
|
|
(if cell2
|
|
|
|
|
(setq timer-idle-list (delq timer timer-idle-list)))
|
|
|
|
|
(or cell1 cell2)))
|
|
|
|
|
|
2003-05-30 23:31:15 +00:00
|
|
|
|
(defun cancel-function-timers (function)
|
2006-09-08 12:00:40 +00:00
|
|
|
|
"Cancel all timers which would run FUNCTION.
|
|
|
|
|
This affects ordinary timers such as are scheduled by `run-at-time',
|
|
|
|
|
and idle timers such as are scheduled by `run-with-idle-timer'."
|
2003-05-30 23:31:15 +00:00
|
|
|
|
(interactive "aCancel timers of function: ")
|
2008-04-03 03:43:18 +00:00
|
|
|
|
(dolist (timer timer-list)
|
|
|
|
|
(if (eq (timer--function timer) function)
|
|
|
|
|
(setq timer-list (delq timer timer-list))))
|
|
|
|
|
(dolist (timer timer-idle-list)
|
|
|
|
|
(if (eq (timer--function timer) function)
|
|
|
|
|
(setq timer-idle-list (delq timer timer-idle-list)))))
|
2003-05-30 23:31:15 +00:00
|
|
|
|
|
|
|
|
|
;; Record the last few events, for debugging.
|
2006-09-08 12:00:40 +00:00
|
|
|
|
(defvar timer-event-last nil
|
|
|
|
|
"Last timer that was run.")
|
|
|
|
|
(defvar timer-event-last-1 nil
|
|
|
|
|
"Next-to-last timer that was run.")
|
|
|
|
|
(defvar timer-event-last-2 nil
|
|
|
|
|
"Third-to-last timer that was run.")
|
2003-05-30 23:31:15 +00:00
|
|
|
|
|
2012-05-04 13:14:14 +08:00
|
|
|
|
(defcustom timer-max-repeats 10
|
2012-04-09 21:05:48 +08:00
|
|
|
|
"Maximum number of times to repeat a timer, if many repeats are delayed.
|
2006-09-24 20:39:52 +00:00
|
|
|
|
Timer invocations can be delayed because Emacs is suspended or busy,
|
|
|
|
|
or because the system's time changes. If such an occurrence makes it
|
|
|
|
|
appear that many invocations are overdue, this variable controls
|
2012-05-04 13:14:14 +08:00
|
|
|
|
how many will really happen."
|
|
|
|
|
:type 'integer
|
|
|
|
|
:group 'internal)
|
2003-05-30 23:31:15 +00:00
|
|
|
|
|
|
|
|
|
(defun timer-until (timer time)
|
|
|
|
|
"Calculate number of seconds from when TIMER will run, until TIME.
|
|
|
|
|
TIMER is a timer, and stands for the time when its next repeat is scheduled.
|
Avoid some double-rounding of Lisp timestamps
Also, simplify some time-related Lisp timestamp code
while we’re in the neighborhood.
* lisp/battery.el (battery-linux-proc-acpi)
(battery-linux-sysfs, battery-upower, battery-bsd-apm):
* lisp/calendar/timeclock.el (timeclock-seconds-to-string)
(timeclock-log, timeclock-last-period)
(timeclock-entry-length, timeclock-entry-list-span)
(timeclock-find-discrep, timeclock-generate-report):
* lisp/cedet/ede/detect.el (ede-detect-qtest):
* lisp/completion.el (cmpl-hours-since-origin):
* lisp/ecomplete.el (ecomplete-decay-1):
* lisp/emacs-lisp/ert.el (ert--results-update-stats-display)
(ert--results-update-stats-display-maybe):
* lisp/emacs-lisp/timer-list.el (list-timers):
* lisp/emacs-lisp/timer.el (timer-until)
(timer-event-handler):
* lisp/erc/erc-backend.el (erc-server-send-ping)
(erc-server-send-queue, erc-handle-parsed-server-response)
(erc-handle-unknown-server-response):
* lisp/erc/erc-track.el (erc-buffer-visible):
* lisp/erc/erc.el (erc-lurker-cleanup, erc-lurker-p)
(erc-cmd-PING, erc-send-current-line):
* lisp/eshell/em-pred.el (eshell-pred-file-time):
* lisp/eshell/em-unix.el (eshell-show-elapsed-time):
* lisp/gnus/gnus-icalendar.el (gnus-icalendar-event:org-timestamp):
* lisp/gnus/gnus-int.el (gnus-backend-trace):
* lisp/gnus/gnus-sum.el (gnus-user-date):
* lisp/gnus/mail-source.el (mail-source-delete-crash-box):
* lisp/gnus/nnmaildir.el (nnmaildir--scan):
* lisp/ibuf-ext.el (ibuffer-mark-old-buffers):
* lisp/gnus/nnmaildir.el (nnmaildir--scan):
* lisp/mouse.el (mouse--down-1-maybe-follows-link)
(mouse--click-1-maybe-follows-link):
* lisp/mpc.el (mpc--faster-toggle):
* lisp/net/rcirc.el (rcirc-handler-ctcp-KEEPALIVE)
(rcirc-sentinel):
* lisp/net/tramp-cache.el (tramp-get-file-property):
* lisp/net/tramp-sh.el (tramp-sh-handle-file-newer-than-file-p)
(tramp-maybe-open-connection):
* lisp/net/tramp-smb.el (tramp-smb-maybe-open-connection):
* lisp/org/org-clock.el (org-clock-resolve):
(org-resolve-clocks, org-clock-in, org-clock-out, org-clock-sum):
* lisp/org/org-timer.el (org-timer-start)
(org-timer-pause-or-continue, org-timer-seconds):
* lisp/org/org.el (org-evaluate-time-range):
* lisp/org/ox-publish.el (org-publish-cache-ctime-of-src):
* lisp/pixel-scroll.el (pixel-scroll-in-rush-p):
* lisp/play/hanoi.el (hanoi-move-ring):
* lisp/proced.el (proced-format-time):
* lisp/progmodes/cpp.el (cpp-progress-message):
* lisp/progmodes/flymake.el (flymake--handle-report):
* lisp/progmodes/js.el (js--wait-for-matching-output):
* lisp/subr.el (progress-reporter-do-update):
* lisp/term/xterm.el (xterm--read-event-for-query):
* lisp/time.el (display-time-update, emacs-uptime):
* lisp/tooltip.el (tooltip-delay):
* lisp/url/url-cookie.el (url-cookie-parse-file-netscape):
* lisp/url/url-queue.el (url-queue-prune-old-entries):
* lisp/url/url.el (url-retrieve-synchronously):
* lisp/xt-mouse.el (xterm-mouse-event):
Avoid double-rounding of time-related values. Simplify.
* lisp/calendar/icalendar.el (icalendar--decode-isodatetime):
When hoping for the best (unlikely), use a better decoded time.
(icalendar--convert-sexp-to-ical): Avoid unnecessary encode-time.
* lisp/calendar/timeclock.el (timeclock-when-to-leave):
* lisp/cedet/ede/detect.el (ede-detect-qtest):
* lisp/desktop.el (desktop-create-buffer):
* lisp/emacs-lisp/benchmark.el (benchmark-elapse):
* lisp/gnus/gnus-art.el (article-lapsed-string):
* lisp/gnus/gnus-group.el (gnus-group-timestamp-delta):
* lisp/gnus/nnmail.el (nnmail-expired-article-p):
* lisp/gnus/nnmaildir.el (nnmaildir-request-expire-articles):
* lisp/nxml/rng-maint.el (rng-time-function):
* lisp/org/org-clock.el (org-clock-get-clocked-time)
(org-clock-resolve, org-resolve-clocks, org-resolve-clocks-if-idle):
* lisp/org/org-habit.el (org-habit-insert-consistency-graphs):
* lisp/progmodes/vhdl-mode.el (vhdl-update-progress-info)
(vhdl-fix-case-region-1):
Use time-since instead of open-coding most of it.
* lisp/erc/erc-dcc.el (erc-dcc-get-sentinel):
* lisp/erc/erc.el (erc-string-to-emacs-time, erc-time-gt):
Now obsolete. All uses changed.
(erc-time-diff): Accept all Lisp time values.
All uses changed.
* lisp/gnus/gnus-demon.el (gnus-demon-idle-since):
* lisp/gnus/gnus-score.el (gnus-score-headers):
* lisp/gnus/nneething.el (nneething-make-head):
* lisp/gnus/nnheader.el (nnheader-message-maybe):
* lisp/gnus/nnimap.el (nnimap-keepalive):
* lisp/image.el (image-animate-timeout):
* lisp/mail/feedmail.el (feedmail-rfc822-date):
* lisp/net/imap.el (imap-wait-for-tag):
* lisp/net/newst-backend.el (newsticker--image-get):
* lisp/net/rcirc.el (rcirc-handler-317, rcirc-handler-333):
* lisp/obsolete/xesam.el (xesam-refresh-entry):
* lisp/org/org-agenda.el (org-agenda-show-clocking-issues)
(org-agenda-check-clock-gap, org-agenda-to-appt):
* lisp/org/org-capture.el (org-capture-set-target-location):
* lisp/org/org-clock.el (org-clock-resolve-clock)
(org-clocktable-steps):
* lisp/org/org-colview.el (org-columns-edit-value)
(org-columns, org-agenda-columns):
* lisp/org/org-duration.el (org-duration-from-minutes):
* lisp/org/org-element.el (org-element-cache-sync-duration)
(org-element-cache-sync-break)
(org-element--cache-interrupt-p, org-element--cache-sync):
* lisp/org/org-habit.el (org-habit-get-faces)
* lisp/org/org-indent.el (org-indent-add-properties):
* lisp/org/org-table.el (org-table-sum):
* lisp/org/org-timer.el (org-timer-show-remaining-time)
(org-timer-set-timer):
* lisp/org/org.el (org-babel-load-file, org-today)
(org-auto-repeat-maybe, org-2ft, org-time-stamp)
(org-read-date-analyze, org-time-stamp-to-now)
(org-small-year-to-year, org-goto-calendar):
* lisp/org/ox.el (org-export-insert-default-template):
* lisp/ses.el (ses--time-check):
* lisp/type-break.el (type-break-time-warning)
(type-break-statistics, type-break-demo-boring):
* lisp/url/url-cache.el (url-cache-expired)
(url-cache-prune-cache):
* lisp/vc/vc-git.el (vc-git-stash-snapshot):
* lisp/erc/erc-match.el (erc-log-matches-come-back):
Simplify.
2019-02-22 18:32:31 -08:00
|
|
|
|
TIME is a Lisp time value."
|
|
|
|
|
(float-time (time-subtract time (timer--time timer))))
|
2003-05-30 23:31:15 +00:00
|
|
|
|
|
|
|
|
|
(defun timer-event-handler (timer)
|
|
|
|
|
"Call the handler for the timer TIMER.
|
|
|
|
|
This function is called, by name, directly by the C code."
|
|
|
|
|
(setq timer-event-last-2 timer-event-last-1)
|
|
|
|
|
(setq timer-event-last-1 timer-event-last)
|
|
|
|
|
(setq timer-event-last timer)
|
|
|
|
|
(let ((inhibit-quit t))
|
2013-04-10 09:31:35 -04:00
|
|
|
|
(timer--check timer)
|
|
|
|
|
(let ((retrigger nil)
|
|
|
|
|
(cell
|
|
|
|
|
;; Delete from queue. Record the cons cell that was used.
|
|
|
|
|
(cancel-timer-internal timer)))
|
2014-05-18 08:58:30 -04:00
|
|
|
|
;; If `cell' is nil, it means the timer was already canceled, so we
|
|
|
|
|
;; shouldn't be running it at all. This can happen for example with the
|
|
|
|
|
;; following scenario (bug#17392):
|
|
|
|
|
;; - we run timers, starting with A (and remembering the rest as (B C)).
|
|
|
|
|
;; - A runs and a does a sit-for.
|
|
|
|
|
;; - during sit-for we run timer D which cancels timer B.
|
|
|
|
|
;; - timer A finally finishes, so we move on to timers B and C.
|
2014-05-18 09:17:10 -04:00
|
|
|
|
(when cell
|
2014-05-18 08:58:30 -04:00
|
|
|
|
;; Re-schedule if requested.
|
|
|
|
|
(if (timer--repeat-delay timer)
|
|
|
|
|
(if (timer--idle-delay timer)
|
|
|
|
|
(timer-activate-when-idle timer nil cell)
|
|
|
|
|
(timer-inc-time timer (timer--repeat-delay timer) 0)
|
|
|
|
|
;; If real time has jumped forward,
|
|
|
|
|
;; perhaps because Emacs was suspended for a long time,
|
|
|
|
|
;; limit how many times things get repeated.
|
|
|
|
|
(if (and (numberp timer-max-repeats)
|
2019-04-24 18:13:04 +03:00
|
|
|
|
(time-less-p (timer--time timer) nil))
|
Improve time stamp handling, and be more consistent about it.
This implements a suggestion made in:
http://lists.gnu.org/archive/html/emacs-devel/2014-10/msg00587.html
Among other things, this means timer.el no longer needs to
autoload the time-date module.
* doc/lispref/os.texi (Time of Day, Time Conversion, Time Parsing)
(Processor Run Time, Time Calculations):
Document the new behavior, plus be clearer about the old behavior.
(Idle Timers): Take advantage of new functionality.
* etc/NEWS: Document the changes.
* lisp/allout-widgets.el (allout-elapsed-time-seconds): Doc fix.
* lisp/arc-mode.el (archive-ar-summarize):
* lisp/calendar/time-date.el (seconds-to-time, days-to-time, time-since):
* lisp/emacs-lisp/timer.el (timer-relative-time, timer-event-handler)
(run-at-time, with-timeout-suspend, with-timeout-unsuspend):
* lisp/net/tramp.el (tramp-time-less-p, tramp-time-subtract):
* lisp/proced.el (proced-time-lessp):
* lisp/timezone.el (timezone-time-from-absolute):
* lisp/type-break.el (type-break-schedule, type-break-time-sum):
Simplify by using new functionality.
* lisp/calendar/cal-dst.el (calendar-next-time-zone-transition):
Do not return time values in obsolete and undocumented (HI . LO)
format; use (HI LO) instead.
* lisp/calendar/time-date.el (with-decoded-time-value):
Treat 'nil' as current time. This is mostly for XEmacs.
(encode-time-value, with-decoded-time-value): Obsolete.
(time-add, time-subtract, time-less-p): Use no-op autoloads, for
XEmacs. Define only if XEmacs, as they're now C builtins in Emacs.
* lisp/ldefs-boot.el: Update to match new time-date.el
* lisp/proced.el: Do not require time-date.
* src/editfns.c (invalid_time): New function.
Use it instead of 'error ("Invalid time specification")'.
(time_add, time_subtract, time_arith, Ftime_add, Ftime_less_p)
(decode_float_time, lisp_to_timespec, lisp_time_struct):
New functions.
(make_time_tail, make_time): Remove. All uses changed to use
new functions or plain list4i.
(disassemble_lisp_time): Return effective length if successful.
Check that LOW is an integer, if it's combined with other components.
(decode_time_components): Decode into struct lisp_time, not
struct timespec, so that we can support a wide set of times
regardless of whether time_t is signed. Decode plain numbers
as seconds since the Epoch, and nil as the current time.
(lisp_time_argument, lisp_seconds_argument, Ffloat_time):
Reimplement in terms of new functions.
(Fencode_time): Just use list2i.
(syms_of_editfns): Add time-add, time-subtract, time-less-p.
* src/keyboard.c (decode_timer): Don't allow the new formats (floating
point or nil) in timers.
* src/systime.h (LO_TIME_BITS): New constant. Use it everywhere in
place of the magic number '16'.
(struct lisp_time): New type.
(decode_time_components): Use it.
(lisp_to_timespec): New decl.
2014-11-16 20:38:15 -08:00
|
|
|
|
(let ((repeats (/ (timer-until timer nil)
|
2014-05-18 08:58:30 -04:00
|
|
|
|
(timer--repeat-delay timer))))
|
|
|
|
|
(if (> repeats timer-max-repeats)
|
|
|
|
|
(timer-inc-time timer (* (timer--repeat-delay timer)
|
|
|
|
|
repeats)))))
|
2021-08-31 03:04:22 +02:00
|
|
|
|
;; If we want integral multiples, we have to recompute
|
|
|
|
|
;; the repetition.
|
2021-09-03 10:40:21 +02:00
|
|
|
|
(when (and (> (length timer) 9) ; Backwards compatible.
|
|
|
|
|
(timer--integral-multiple timer)
|
2021-08-31 03:04:22 +02:00
|
|
|
|
(not (timer--idle-delay timer)))
|
|
|
|
|
(setf (timer--time timer)
|
|
|
|
|
(timer-next-integral-multiple-of-time
|
2021-12-05 18:25:46 -08:00
|
|
|
|
nil (timer--repeat-delay timer))))
|
2014-05-18 08:58:30 -04:00
|
|
|
|
;; Place it back on the timer-list before running
|
|
|
|
|
;; timer--function, so it can cancel-timer itself.
|
|
|
|
|
(timer-activate timer t cell)
|
|
|
|
|
(setq retrigger t)))
|
|
|
|
|
;; Run handler.
|
|
|
|
|
(condition-case-unless-debug err
|
|
|
|
|
;; Timer functions should not change the current buffer.
|
|
|
|
|
;; If they do, all kinds of nasty surprises can happen,
|
|
|
|
|
;; and it can be hellish to track down their source.
|
|
|
|
|
(save-current-buffer
|
|
|
|
|
(apply (timer--function timer) (timer--args timer)))
|
|
|
|
|
(error (message "Error running timer%s: %S"
|
|
|
|
|
(if (symbolp (timer--function timer))
|
Go back to grave quoting in source-code docstrings etc.
This reverts almost all my recent changes to use curved quotes
in docstrings and/or strings used for error diagnostics.
There are a few exceptions, e.g., Bahá’í proper names.
* admin/unidata/unidata-gen.el (unidata-gen-table):
* lisp/abbrev.el (expand-region-abbrevs):
* lisp/align.el (align-region):
* lisp/allout.el (allout-mode, allout-solicit-alternate-bullet)
(outlineify-sticky):
* lisp/apropos.el (apropos-library):
* lisp/bookmark.el (bookmark-default-annotation-text):
* lisp/button.el (button-category-symbol, button-put)
(make-text-button):
* lisp/calc/calc-aent.el (math-read-if, math-read-factor):
* lisp/calc/calc-embed.el (calc-do-embedded):
* lisp/calc/calc-ext.el (calc-user-function-list):
* lisp/calc/calc-graph.el (calc-graph-show-dumb):
* lisp/calc/calc-help.el (calc-describe-key)
(calc-describe-thing, calc-full-help):
* lisp/calc/calc-lang.el (calc-c-language)
(math-parse-fortran-vector-end, math-parse-tex-sum)
(math-parse-eqn-matrix, math-parse-eqn-prime)
(calc-yacas-language, calc-maxima-language, calc-giac-language)
(math-read-giac-subscr, math-read-math-subscr)
(math-read-big-rec, math-read-big-balance):
* lisp/calc/calc-misc.el (calc-help, report-calc-bug):
* lisp/calc/calc-mode.el (calc-auto-why, calc-save-modes)
(calc-auto-recompute):
* lisp/calc/calc-prog.el (calc-fix-token-name)
(calc-read-parse-table-part, calc-user-define-invocation)
(math-do-arg-check):
* lisp/calc/calc-store.el (calc-edit-variable):
* lisp/calc/calc-units.el (math-build-units-table-buffer):
* lisp/calc/calc-vec.el (math-read-brackets):
* lisp/calc/calc-yank.el (calc-edit-mode):
* lisp/calc/calc.el (calc, calc-do, calc-user-invocation):
* lisp/calendar/appt.el (appt-display-message):
* lisp/calendar/diary-lib.el (diary-check-diary-file)
(diary-mail-entries, diary-from-outlook):
* lisp/calendar/icalendar.el (icalendar-export-region)
(icalendar--convert-float-to-ical)
(icalendar--convert-date-to-ical)
(icalendar--convert-ical-to-diary)
(icalendar--convert-recurring-to-diary)
(icalendar--add-diary-entry):
* lisp/calendar/time-date.el (format-seconds):
* lisp/calendar/timeclock.el (timeclock-mode-line-display)
(timeclock-make-hours-explicit, timeclock-log-data):
* lisp/calendar/todo-mode.el (todo-prefix, todo-delete-category)
(todo-item-mark, todo-check-format)
(todo-insert-item--next-param, todo-edit-item--next-key)
(todo-mode):
* lisp/cedet/ede/pmake.el (ede-proj-makefile-insert-dist-rules):
* lisp/cedet/mode-local.el (describe-mode-local-overload)
(mode-local-print-binding, mode-local-describe-bindings-2):
* lisp/cedet/semantic/complete.el (semantic-displayor-show-request):
* lisp/cedet/srecode/srt-mode.el (srecode-macro-help):
* lisp/cus-start.el (standard):
* lisp/cus-theme.el (describe-theme-1):
* lisp/custom.el (custom-add-dependencies, custom-check-theme)
(custom--sort-vars-1, load-theme):
* lisp/descr-text.el (describe-text-properties-1, describe-char):
* lisp/dired-x.el (dired-do-run-mail):
* lisp/dired.el (dired-log):
* lisp/emacs-lisp/advice.el (ad-read-advised-function)
(ad-read-advice-class, ad-read-advice-name, ad-enable-advice)
(ad-disable-advice, ad-remove-advice, ad-set-argument)
(ad-set-arguments, ad--defalias-fset, ad-activate)
(ad-deactivate):
* lisp/emacs-lisp/byte-opt.el (byte-compile-inline-expand)
(byte-compile-unfold-lambda, byte-optimize-form-code-walker)
(byte-optimize-while, byte-optimize-apply):
* lisp/emacs-lisp/byte-run.el (defun, defsubst):
* lisp/emacs-lisp/bytecomp.el (byte-compile-lapcode)
(byte-compile-log-file, byte-compile-format-warn)
(byte-compile-nogroup-warn, byte-compile-arglist-warn)
(byte-compile-cl-warn)
(byte-compile-warn-about-unresolved-functions)
(byte-compile-file, byte-compile--declare-var)
(byte-compile-file-form-defmumble, byte-compile-form)
(byte-compile-normal-call, byte-compile-check-variable)
(byte-compile-variable-ref, byte-compile-variable-set)
(byte-compile-subr-wrong-args, byte-compile-setq-default)
(byte-compile-negation-optimizer)
(byte-compile-condition-case--old)
(byte-compile-condition-case--new, byte-compile-save-excursion)
(byte-compile-defvar, byte-compile-autoload)
(byte-compile-lambda-form)
(byte-compile-make-variable-buffer-local, display-call-tree)
(batch-byte-compile):
* lisp/emacs-lisp/cconv.el (cconv-convert, cconv--analyze-use):
* lisp/emacs-lisp/chart.el (chart-space-usage):
* lisp/emacs-lisp/check-declare.el (check-declare-scan)
(check-declare-warn, check-declare-file)
(check-declare-directory):
* lisp/emacs-lisp/checkdoc.el (checkdoc-this-string-valid-engine)
(checkdoc-message-text-engine):
* lisp/emacs-lisp/cl-extra.el (cl-parse-integer)
(cl--describe-class):
* lisp/emacs-lisp/cl-generic.el (cl-defgeneric)
(cl--generic-describe, cl-generic-generalizers):
* lisp/emacs-lisp/cl-macs.el (cl--parse-loop-clause, cl-tagbody)
(cl-symbol-macrolet):
* lisp/emacs-lisp/cl.el (cl-unload-function, flet):
* lisp/emacs-lisp/copyright.el (copyright)
(copyright-update-directory):
* lisp/emacs-lisp/edebug.el (edebug-read-list):
* lisp/emacs-lisp/eieio-base.el (eieio-persistent-read):
* lisp/emacs-lisp/eieio-core.el (eieio--slot-override)
(eieio-oref):
* lisp/emacs-lisp/eieio-opt.el (eieio-help-constructor):
* lisp/emacs-lisp/eieio-speedbar.el:
(eieio-speedbar-child-make-tag-lines)
(eieio-speedbar-child-description):
* lisp/emacs-lisp/eieio.el (defclass, change-class):
* lisp/emacs-lisp/elint.el (elint-file, elint-get-top-forms)
(elint-init-form, elint-check-defalias-form)
(elint-check-let-form):
* lisp/emacs-lisp/ert.el (ert-get-test, ert-results-mode-menu)
(ert-results-pop-to-backtrace-for-test-at-point)
(ert-results-pop-to-messages-for-test-at-point)
(ert-results-pop-to-should-forms-for-test-at-point)
(ert-describe-test):
* lisp/emacs-lisp/find-func.el (find-function-search-for-symbol)
(find-function-library):
* lisp/emacs-lisp/generator.el (iter-yield):
* lisp/emacs-lisp/gv.el (gv-define-simple-setter):
* lisp/emacs-lisp/lisp-mnt.el (lm-verify):
* lisp/emacs-lisp/macroexp.el (macroexp--obsolete-warning):
* lisp/emacs-lisp/map-ynp.el (map-y-or-n-p):
* lisp/emacs-lisp/nadvice.el (advice--make-docstring)
(advice--make, define-advice):
* lisp/emacs-lisp/package-x.el (package-upload-file):
* lisp/emacs-lisp/package.el (package-version-join)
(package-disabled-p, package-activate-1, package-activate)
(package--download-one-archive)
(package--download-and-read-archives)
(package-compute-transaction, package-install-from-archive)
(package-install, package-install-selected-packages)
(package-delete, package-autoremove, describe-package-1)
(package-install-button-action, package-delete-button-action)
(package-menu-hide-package, package-menu--list-to-prompt)
(package-menu--perform-transaction)
(package-menu--find-and-notify-upgrades):
* lisp/emacs-lisp/pcase.el (pcase-exhaustive, pcase--u1):
* lisp/emacs-lisp/re-builder.el (reb-enter-subexp-mode):
* lisp/emacs-lisp/ring.el (ring-previous, ring-next):
* lisp/emacs-lisp/rx.el (rx-check, rx-anything)
(rx-check-any-string, rx-check-any, rx-check-not, rx-=)
(rx-repeat, rx-check-backref, rx-syntax, rx-check-category)
(rx-form):
* lisp/emacs-lisp/smie.el (smie-config-save):
* lisp/emacs-lisp/subr-x.el (internal--check-binding):
* lisp/emacs-lisp/tabulated-list.el (tabulated-list-put-tag):
* lisp/emacs-lisp/testcover.el (testcover-1value):
* lisp/emacs-lisp/timer.el (timer-event-handler):
* lisp/emulation/viper-cmd.el (viper-toggle-parse-sexp-ignore-comments)
(viper-toggle-search-style, viper-kill-buffer)
(viper-brac-function):
* lisp/emulation/viper-macs.el (viper-record-kbd-macro):
* lisp/env.el (setenv):
* lisp/erc/erc-button.el (erc-nick-popup):
* lisp/erc/erc.el (erc-cmd-LOAD, erc-handle-login, english):
* lisp/eshell/em-dirs.el (eshell/cd):
* lisp/eshell/em-glob.el (eshell-glob-regexp)
(eshell-glob-entries):
* lisp/eshell/em-pred.el (eshell-parse-modifiers):
* lisp/eshell/esh-opt.el (eshell-show-usage):
* lisp/facemenu.el (facemenu-add-new-face)
(facemenu-add-new-color):
* lisp/faces.el (read-face-name, read-face-font, describe-face)
(x-resolve-font-name):
* lisp/files-x.el (modify-file-local-variable):
* lisp/files.el (locate-user-emacs-file, find-alternate-file)
(set-auto-mode, hack-one-local-variable--obsolete)
(dir-locals-set-directory-class, write-file, basic-save-buffer)
(delete-directory, copy-directory, recover-session)
(recover-session-finish, insert-directory)
(file-modes-char-to-who, file-modes-symbolic-to-number)
(move-file-to-trash):
* lisp/filesets.el (filesets-add-buffer, filesets-remove-buffer):
* lisp/find-cmd.el (find-generic, find-to-string):
* lisp/finder.el (finder-commentary):
* lisp/font-lock.el (font-lock-fontify-buffer):
* lisp/format.el (format-write-file, format-find-file)
(format-insert-file):
* lisp/frame.el (get-device-terminal, select-frame-by-name):
* lisp/fringe.el (fringe--check-style):
* lisp/gnus/nnmairix.el (nnmairix-widget-create-query):
* lisp/help-fns.el (help-fns--key-bindings)
(help-fns--compiler-macro, help-fns--parent-mode)
(help-fns--obsolete, help-fns--interactive-only)
(describe-function-1, describe-variable):
* lisp/help.el (describe-mode)
(describe-minor-mode-from-indicator):
* lisp/image.el (image-type):
* lisp/international/ccl.el (ccl-dump):
* lisp/international/fontset.el (x-must-resolve-font-name):
* lisp/international/mule-cmds.el (prefer-coding-system)
(select-safe-coding-system-interactively)
(select-safe-coding-system, activate-input-method)
(toggle-input-method, describe-current-input-method)
(describe-language-environment):
* lisp/international/mule-conf.el (code-offset):
* lisp/international/mule-diag.el (describe-character-set)
(list-input-methods-1):
* lisp/mail/feedmail.el (feedmail-run-the-queue):
* lisp/mouse.el (minor-mode-menu-from-indicator):
* lisp/mpc.el (mpc-playlist-rename):
* lisp/msb.el (msb--choose-menu):
* lisp/net/ange-ftp.el (ange-ftp-shell-command):
* lisp/net/imap.el (imap-interactive-login):
* lisp/net/mairix.el (mairix-widget-create-query):
* lisp/net/newst-backend.el (newsticker--sentinel-work):
* lisp/net/newst-treeview.el (newsticker--treeview-load):
* lisp/net/rlogin.el (rlogin):
* lisp/obsolete/iswitchb.el (iswitchb-possible-new-buffer):
* lisp/obsolete/otodo-mode.el (todo-more-important-p):
* lisp/obsolete/pgg-gpg.el (pgg-gpg-process-region):
* lisp/obsolete/pgg-pgp.el (pgg-pgp-process-region):
* lisp/obsolete/pgg-pgp5.el (pgg-pgp5-process-region):
* lisp/org/ob-core.el (org-babel-goto-named-src-block)
(org-babel-goto-named-result):
* lisp/org/ob-fortran.el (org-babel-fortran-ensure-main-wrap):
* lisp/org/ob-ref.el (org-babel-ref-resolve):
* lisp/org/org-agenda.el (org-agenda-prepare):
* lisp/org/org-clock.el (org-clock-notify-once-if-expired)
(org-clock-resolve):
* lisp/org/org-ctags.el (org-ctags-ask-rebuild-tags-file-then-find-tag):
* lisp/org/org-feed.el (org-feed-parse-atom-entry):
* lisp/org/org-habit.el (org-habit-parse-todo):
* lisp/org/org-mouse.el (org-mouse-popup-global-menu)
(org-mouse-context-menu):
* lisp/org/org-table.el (org-table-edit-formulas):
* lisp/org/ox.el (org-export-async-start):
* lisp/proced.el (proced-log):
* lisp/progmodes/ada-mode.el (ada-get-indent-case)
(ada-check-matching-start, ada-goto-matching-start):
* lisp/progmodes/ada-prj.el (ada-prj-display-page):
* lisp/progmodes/ada-xref.el (ada-find-executable):
* lisp/progmodes/ebrowse.el (ebrowse-tags-apropos):
* lisp/progmodes/etags.el (etags-tags-apropos-additional):
* lisp/progmodes/flymake.el (flymake-parse-err-lines)
(flymake-start-syntax-check-process):
* lisp/progmodes/python.el (python-shell-get-process-or-error)
(python-define-auxiliary-skeleton):
* lisp/progmodes/sql.el (sql-comint):
* lisp/progmodes/verilog-mode.el (verilog-load-file-at-point):
* lisp/progmodes/vhdl-mode.el (vhdl-widget-directory-validate):
* lisp/recentf.el (recentf-open-files):
* lisp/replace.el (query-replace-read-from)
(occur-after-change-function, occur-1):
* lisp/scroll-bar.el (scroll-bar-columns):
* lisp/server.el (server-get-auth-key):
* lisp/simple.el (execute-extended-command)
(undo-outer-limit-truncate, list-processes--refresh)
(compose-mail, set-variable, choose-completion-string)
(define-alternatives):
* lisp/startup.el (site-run-file, tty-handle-args, command-line)
(command-line-1):
* lisp/subr.el (noreturn, define-error, add-to-list)
(read-char-choice, version-to-list):
* lisp/term/common-win.el (x-handle-xrm-switch)
(x-handle-name-switch, x-handle-args):
* lisp/term/x-win.el (x-handle-parent-id, x-handle-smid):
* lisp/textmodes/reftex-ref.el (reftex-label):
* lisp/textmodes/reftex-toc.el (reftex-toc-rename-label):
* lisp/textmodes/two-column.el (2C-split):
* lisp/tutorial.el (tutorial--describe-nonstandard-key)
(tutorial--find-changed-keys):
* lisp/type-break.el (type-break-noninteractive-query):
* lisp/wdired.el (wdired-do-renames, wdired-do-symlink-changes)
(wdired-do-perm-changes):
* lisp/whitespace.el (whitespace-report-region):
Prefer grave quoting in source-code strings used to generate help
and diagnostics.
* lisp/faces.el (face-documentation):
No need to convert quotes, since the result is a docstring.
* lisp/info.el (Info-virtual-index-find-node)
(Info-virtual-index, info-apropos):
Simplify by generating only curved quotes, since info files are
typically that ways nowadays anyway.
* lisp/international/mule-diag.el (list-input-methods):
Don’t assume text quoting style is curved.
* lisp/org/org-bibtex.el (org-bibtex-fields):
Revert my recent changes, going back to the old quoting style.
2015-09-07 08:41:44 -07:00
|
|
|
|
(format-message " `%s'" (timer--function timer))
|
More-conservative ‘format’ quote restyling
Instead of restyling curved quotes for every call to ‘format’,
create a new function ‘format-message’ that does the restyling,
and using the new function instead of ‘format’ only in contexts
where this seems appropriate.
Problem reported by Dmitry Gutov and Andreas Schwab in:
http://lists.gnu.org/archive/html/emacs-devel/2015-08/msg00826.html
http://lists.gnu.org/archive/html/emacs-devel/2015-08/msg00827.html
* doc/lispref/commands.texi (Using Interactive):
* doc/lispref/control.texi (Signaling Errors, Signaling Errors):
* doc/lispref/display.texi (Displaying Messages, Progress):
* doc/lispref/elisp.texi:
* doc/lispref/help.texi (Keys in Documentation):
* doc/lispref/minibuf.texi (Minibuffer Misc):
* doc/lispref/strings.texi (Formatting Strings):
* etc/NEWS:
Document the changes.
* lisp/abbrev.el (expand-region-abbrevs):
* lisp/apropos.el (apropos-library):
* lisp/calc/calc-ext.el (calc-record-message)
(calc-user-function-list):
* lisp/calc/calc-help.el (calc-describe-key, calc-full-help):
* lisp/calc/calc-lang.el (math-read-big-balance):
* lisp/calc/calc-store.el (calc-edit-variable):
* lisp/calc/calc-units.el (math-build-units-table-buffer):
* lisp/calc/calc-yank.el (calc-edit-mode):
* lisp/calendar/icalendar.el (icalendar-export-region)
(icalendar--add-diary-entry):
* lisp/cedet/mode-local.el (mode-local-print-binding)
(mode-local-describe-bindings-2):
* lisp/cedet/semantic/complete.el (semantic-completion-message):
* lisp/cedet/semantic/edit.el (semantic-parse-changes-failed):
* lisp/cedet/semantic/wisent/comp.el (wisent-log):
* lisp/cedet/srecode/insert.el (srecode-insert-show-error-report):
* lisp/descr-text.el (describe-text-properties-1, describe-char):
* lisp/dframe.el (dframe-message):
* lisp/dired-aux.el (dired-query):
* lisp/emacs-lisp/byte-opt.el (byte-compile-log-lap-1):
* lisp/emacs-lisp/bytecomp.el (byte-compile-log)
(byte-compile-log-file, byte-compile-warn, byte-compile-form):
* lisp/emacs-lisp/cconv.el (cconv-convert, cconv--analyze-use)
(cconv-analyze-form):
* lisp/emacs-lisp/check-declare.el (check-declare-warn):
* lisp/emacs-lisp/checkdoc.el (checkdoc-this-string-valid-engine):
* lisp/emacs-lisp/cl-macs.el (cl-symbol-macrolet):
* lisp/emacs-lisp/edebug.el (edebug-format):
* lisp/emacs-lisp/eieio-core.el (eieio-oref):
* lisp/emacs-lisp/eldoc.el (eldoc-minibuffer-message)
(eldoc-message):
* lisp/emacs-lisp/elint.el (elint-file, elint-log):
* lisp/emacs-lisp/find-func.el (find-function-library):
* lisp/emacs-lisp/macroexp.el (macroexp--obsolete-warning):
* lisp/emacs-lisp/map-ynp.el (map-y-or-n-p):
* lisp/emacs-lisp/nadvice.el (advice--make-docstring):
* lisp/emacs-lisp/package.el (package-compute-transaction)
(package-install-button-action, package-delete-button-action)
(package-menu--list-to-prompt):
* lisp/emacs-lisp/timer.el (timer-event-handler):
* lisp/emacs-lisp/warnings.el (lwarn, warn):
* lisp/emulation/viper-cmd.el:
(viper-toggle-parse-sexp-ignore-comments)
(viper-kill-buffer, viper-brac-function):
* lisp/emulation/viper-macs.el (viper-record-kbd-macro):
* lisp/facemenu.el (facemenu-add-new-face):
* lisp/faces.el (face-documentation, read-face-name)
(face-read-string, read-face-font, describe-face):
* lisp/files.el (find-alternate-file, hack-local-variables)
(hack-one-local-variable--obsolete, write-file)
(basic-save-buffer, delete-directory):
* lisp/format.el (format-write-file, format-find-file)
(format-insert-file):
* lisp/help-fns.el (help-fns--key-bindings)
(help-fns--compiler-macro, help-fns--obsolete)
(help-fns--interactive-only, describe-function-1)
(describe-variable):
* lisp/help.el (describe-mode):
* lisp/info-xref.el (info-xref-output):
* lisp/info.el (Info-virtual-index-find-node)
(Info-virtual-index, info-apropos):
* lisp/international/kkc.el (kkc-error):
* lisp/international/mule-cmds.el:
(select-safe-coding-system-interactively)
(select-safe-coding-system, describe-input-method):
* lisp/international/mule-conf.el (code-offset):
* lisp/international/mule-diag.el (describe-character-set)
(list-input-methods-1):
* lisp/international/quail.el (quail-error):
* lisp/minibuffer.el (minibuffer-message):
* lisp/mpc.el (mpc--debug):
* lisp/msb.el (msb--choose-menu):
* lisp/net/ange-ftp.el (ange-ftp-message):
* lisp/net/gnutls.el (gnutls-message-maybe):
* lisp/net/newst-backend.el (newsticker--sentinel-work):
* lisp/net/newst-treeview.el (newsticker--treeview-load):
* lisp/net/nsm.el (nsm-query-user):
* lisp/net/rlogin.el (rlogin):
* lisp/net/soap-client.el (soap-warning):
* lisp/net/tramp.el (tramp-debug-message):
* lisp/nxml/nxml-outln.el (nxml-report-outline-error):
* lisp/nxml/nxml-parse.el (nxml-parse-error):
* lisp/nxml/rng-cmpct.el (rng-c-error):
* lisp/nxml/rng-match.el (rng-compile-error):
* lisp/nxml/rng-uri.el (rng-uri-error):
* lisp/obsolete/iswitchb.el (iswitchb-possible-new-buffer):
* lisp/org/org-ctags.el:
(org-ctags-ask-rebuild-tags-file-then-find-tag):
* lisp/proced.el (proced-log):
* lisp/progmodes/ebnf2ps.el (ebnf-log):
* lisp/progmodes/flymake.el (flymake-log):
* lisp/progmodes/vhdl-mode.el (vhdl-warning-when-idle):
* lisp/replace.el (occur-1):
* lisp/simple.el (execute-extended-command)
(undo-outer-limit-truncate, define-alternatives):
* lisp/startup.el (command-line):
* lisp/subr.el (error, user-error, add-to-list):
* lisp/tutorial.el (tutorial--describe-nonstandard-key)
(tutorial--find-changed-keys):
* src/callint.c (Fcall_interactively):
* src/editfns.c (Fmessage, Fmessage_box):
Restyle the quotes of format strings intended for use as a
diagnostic, when restyling seems appropriate.
* lisp/subr.el (format-message): New function.
* src/doc.c (Finternal__text_restyle): New function.
(syms_of_doc): Define it.
2015-08-23 22:38:02 -07:00
|
|
|
|
"")
|
2014-05-18 08:58:30 -04:00
|
|
|
|
err)))
|
|
|
|
|
(when (and retrigger
|
|
|
|
|
;; If the timer's been canceled, don't "retrigger" it
|
|
|
|
|
;; since it might still be in the copy of timer-list kept
|
|
|
|
|
;; by keyboard.c:timer_check (bug#14156).
|
|
|
|
|
(memq timer timer-list))
|
|
|
|
|
(setf (timer--triggered timer) nil))))))
|
2003-05-30 23:31:15 +00:00
|
|
|
|
|
|
|
|
|
;; This function is incompatible with the one in levents.el.
|
|
|
|
|
(defun timeout-event-p (event)
|
|
|
|
|
"Non-nil if EVENT is a timeout event."
|
|
|
|
|
(and (listp event) (eq (car event) 'timer-event)))
|
|
|
|
|
|
2007-11-20 00:57:10 +00:00
|
|
|
|
|
2007-12-06 04:09:57 +00:00
|
|
|
|
(declare-function diary-entry-time "diary-lib" (s))
|
2007-11-20 00:57:10 +00:00
|
|
|
|
|
2003-05-30 23:31:15 +00:00
|
|
|
|
(defun run-at-time (time repeat function &rest args)
|
|
|
|
|
"Perform an action at time TIME.
|
|
|
|
|
Repeat the action every REPEAT seconds, if REPEAT is non-nil.
|
2015-09-20 09:34:24 +03:00
|
|
|
|
REPEAT may be an integer or floating point number.
|
2015-09-19 21:39:09 +01:00
|
|
|
|
TIME should be one of:
|
2021-12-03 17:22:54 +01:00
|
|
|
|
|
2015-09-20 09:34:24 +03:00
|
|
|
|
- a string giving today's time like \"11:23pm\"
|
|
|
|
|
(the acceptable formats are HHMM, H:MM, HH:MM, HHam, HHAM,
|
|
|
|
|
HHpm, HHPM, HH:MMam, HH:MMAM, HH:MMpm, or HH:MMPM;
|
2015-09-20 09:45:04 -07:00
|
|
|
|
a period `.' can be used instead of a colon `:' to separate
|
2015-09-20 09:34:24 +03:00
|
|
|
|
the hour and minute parts);
|
2021-12-03 17:22:54 +01:00
|
|
|
|
|
2015-09-20 09:34:24 +03:00
|
|
|
|
- a string giving a relative time like \"90\" or \"2 hours 35 minutes\"
|
|
|
|
|
(the acceptable forms are a number of seconds without units
|
|
|
|
|
or some combination of values using units in `timer-duration-words');
|
2021-12-03 17:22:54 +01:00
|
|
|
|
|
2015-09-20 09:34:24 +03:00
|
|
|
|
- nil, meaning now;
|
2021-12-03 17:22:54 +01:00
|
|
|
|
|
2015-09-19 21:39:09 +01:00
|
|
|
|
- a number of seconds from now;
|
2021-12-03 17:22:54 +01:00
|
|
|
|
|
2015-09-19 21:39:09 +01:00
|
|
|
|
- a value from `encode-time';
|
2021-12-03 17:22:54 +01:00
|
|
|
|
|
|
|
|
|
- or t (with non-nil REPEAT) meaning the next integral multiple
|
|
|
|
|
of REPEAT. This is handy when you want the function to run at
|
|
|
|
|
a certain \"round\" number. For instance, (run-at-time t 60 ...)
|
|
|
|
|
will run at 11:04:00, 11:05:00, etc.
|
2015-09-19 21:39:09 +01:00
|
|
|
|
|
2015-09-20 09:34:24 +03:00
|
|
|
|
The action is to call FUNCTION with arguments ARGS.
|
2015-09-19 21:39:09 +01:00
|
|
|
|
|
|
|
|
|
This function returns a timer object which you can use in
|
|
|
|
|
`cancel-timer'."
|
2003-05-30 23:31:15 +00:00
|
|
|
|
(interactive "sRun at time: \nNRepeat interval: \naFunction: ")
|
|
|
|
|
|
2021-08-31 03:04:22 +02:00
|
|
|
|
(when (and repeat
|
|
|
|
|
(numberp repeat)
|
|
|
|
|
(< repeat 0))
|
|
|
|
|
(error "Invalid repetition interval"))
|
2003-05-30 23:31:15 +00:00
|
|
|
|
|
2021-08-31 03:04:22 +02:00
|
|
|
|
(let ((timer (timer-create)))
|
|
|
|
|
;; Special case: nil means "now" and is useful when repeating.
|
|
|
|
|
(unless time
|
2003-05-30 23:31:15 +00:00
|
|
|
|
(setq time (current-time)))
|
|
|
|
|
|
2021-08-31 03:04:22 +02:00
|
|
|
|
;; Special case: t means the next integral multiple of REPEAT.
|
|
|
|
|
(when (and (eq time t) repeat)
|
2021-12-05 18:25:46 -08:00
|
|
|
|
(setq time (timer-next-integral-multiple-of-time nil repeat))
|
2021-08-31 03:04:22 +02:00
|
|
|
|
(setf (timer--integral-multiple timer) t))
|
2003-05-30 23:31:15 +00:00
|
|
|
|
|
2021-08-31 03:04:22 +02:00
|
|
|
|
;; Handle numbers as relative times in seconds.
|
|
|
|
|
(when (numberp time)
|
Improve time stamp handling, and be more consistent about it.
This implements a suggestion made in:
http://lists.gnu.org/archive/html/emacs-devel/2014-10/msg00587.html
Among other things, this means timer.el no longer needs to
autoload the time-date module.
* doc/lispref/os.texi (Time of Day, Time Conversion, Time Parsing)
(Processor Run Time, Time Calculations):
Document the new behavior, plus be clearer about the old behavior.
(Idle Timers): Take advantage of new functionality.
* etc/NEWS: Document the changes.
* lisp/allout-widgets.el (allout-elapsed-time-seconds): Doc fix.
* lisp/arc-mode.el (archive-ar-summarize):
* lisp/calendar/time-date.el (seconds-to-time, days-to-time, time-since):
* lisp/emacs-lisp/timer.el (timer-relative-time, timer-event-handler)
(run-at-time, with-timeout-suspend, with-timeout-unsuspend):
* lisp/net/tramp.el (tramp-time-less-p, tramp-time-subtract):
* lisp/proced.el (proced-time-lessp):
* lisp/timezone.el (timezone-time-from-absolute):
* lisp/type-break.el (type-break-schedule, type-break-time-sum):
Simplify by using new functionality.
* lisp/calendar/cal-dst.el (calendar-next-time-zone-transition):
Do not return time values in obsolete and undocumented (HI . LO)
format; use (HI LO) instead.
* lisp/calendar/time-date.el (with-decoded-time-value):
Treat 'nil' as current time. This is mostly for XEmacs.
(encode-time-value, with-decoded-time-value): Obsolete.
(time-add, time-subtract, time-less-p): Use no-op autoloads, for
XEmacs. Define only if XEmacs, as they're now C builtins in Emacs.
* lisp/ldefs-boot.el: Update to match new time-date.el
* lisp/proced.el: Do not require time-date.
* src/editfns.c (invalid_time): New function.
Use it instead of 'error ("Invalid time specification")'.
(time_add, time_subtract, time_arith, Ftime_add, Ftime_less_p)
(decode_float_time, lisp_to_timespec, lisp_time_struct):
New functions.
(make_time_tail, make_time): Remove. All uses changed to use
new functions or plain list4i.
(disassemble_lisp_time): Return effective length if successful.
Check that LOW is an integer, if it's combined with other components.
(decode_time_components): Decode into struct lisp_time, not
struct timespec, so that we can support a wide set of times
regardless of whether time_t is signed. Decode plain numbers
as seconds since the Epoch, and nil as the current time.
(lisp_time_argument, lisp_seconds_argument, Ffloat_time):
Reimplement in terms of new functions.
(Fencode_time): Just use list2i.
(syms_of_editfns): Add time-add, time-subtract, time-less-p.
* src/keyboard.c (decode_timer): Don't allow the new formats (floating
point or nil) in timers.
* src/systime.h (LO_TIME_BITS): New constant. Use it everywhere in
place of the magic number '16'.
(struct lisp_time): New type.
(decode_time_components): Use it.
(lisp_to_timespec): New decl.
2014-11-16 20:38:15 -08:00
|
|
|
|
(setq time (timer-relative-time nil time)))
|
2003-05-30 23:31:15 +00:00
|
|
|
|
|
2021-08-31 03:04:22 +02:00
|
|
|
|
;; Handle relative times like "2 hours 35 minutes".
|
|
|
|
|
(when (stringp time)
|
|
|
|
|
(when-let ((secs (timer-duration time)))
|
|
|
|
|
(setq time (timer-relative-time nil secs))))
|
|
|
|
|
|
|
|
|
|
;; Handle "11:23pm" and the like. Interpret it as meaning today
|
|
|
|
|
;; which admittedly is rather stupid if we have passed that time
|
|
|
|
|
;; already. (Though only Emacs hackers hack Emacs at that time.)
|
|
|
|
|
(when (stringp time)
|
|
|
|
|
(require 'diary-lib)
|
|
|
|
|
(let ((hhmm (diary-entry-time time))
|
|
|
|
|
(now (decode-time)))
|
|
|
|
|
(when (>= hhmm 0)
|
|
|
|
|
(setq time (encode-time 0 (% hhmm 100) (/ hhmm 100)
|
|
|
|
|
(decoded-time-day now)
|
|
|
|
|
(decoded-time-month now)
|
|
|
|
|
(decoded-time-year now)
|
|
|
|
|
(decoded-time-zone now))))))
|
2003-05-30 23:31:15 +00:00
|
|
|
|
|
|
|
|
|
(timer-set-time timer time repeat)
|
|
|
|
|
(timer-set-function timer function args)
|
|
|
|
|
(timer-activate timer)
|
|
|
|
|
timer))
|
|
|
|
|
|
|
|
|
|
(defun 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.
|
|
|
|
|
|
|
|
|
|
This function returns a timer object which you can use in `cancel-timer'."
|
|
|
|
|
(interactive "sRun after delay (seconds): \nNRepeat interval: \naFunction: ")
|
2022-08-05 10:38:59 -04:00
|
|
|
|
(apply #'run-at-time secs repeat function args))
|
2003-05-30 23:31:15 +00:00
|
|
|
|
|
|
|
|
|
(defun add-timeout (secs function object &optional repeat)
|
|
|
|
|
"Add a timer to run SECS seconds from now, to call FUNCTION on OBJECT.
|
|
|
|
|
If REPEAT is non-nil, repeat the timer every REPEAT seconds.
|
2016-04-30 20:16:25 +02:00
|
|
|
|
|
|
|
|
|
This function returns a timer object which you can use in `cancel-timer'.
|
2003-05-30 23:31:15 +00:00
|
|
|
|
This function is for compatibility; see also `run-with-timer'."
|
|
|
|
|
(run-with-timer secs repeat function object))
|
|
|
|
|
|
|
|
|
|
(defun run-with-idle-timer (secs repeat function &rest args)
|
|
|
|
|
"Perform an action the next time Emacs is idle for SECS seconds.
|
|
|
|
|
The action is to call FUNCTION with arguments ARGS.
|
2006-08-24 23:40:00 +00:00
|
|
|
|
SECS may be an integer, a floating point number, or the internal
|
2012-06-22 14:17:42 -07:00
|
|
|
|
time format returned by, e.g., `current-idle-time'.
|
2006-08-20 12:16:26 +00:00
|
|
|
|
If Emacs is currently idle, and has been idle for N seconds (N < SECS),
|
2012-09-22 16:16:03 +03:00
|
|
|
|
then it will call FUNCTION in SECS - N seconds from now. Using
|
|
|
|
|
SECS <= N is not recommended if this function is invoked from an idle
|
|
|
|
|
timer, because FUNCTION will then be called immediately.
|
2003-05-30 23:31:15 +00:00
|
|
|
|
|
|
|
|
|
If REPEAT is non-nil, do the action each time Emacs has been idle for
|
|
|
|
|
exactly SECS seconds (that is, only once for each time Emacs becomes idle).
|
|
|
|
|
|
|
|
|
|
This function returns a timer object which you can use in `cancel-timer'."
|
|
|
|
|
(interactive
|
|
|
|
|
(list (read-from-minibuffer "Run after idle (seconds): " nil nil t)
|
|
|
|
|
(y-or-n-p "Repeat each time Emacs is idle? ")
|
2022-08-05 10:38:59 -04:00
|
|
|
|
(intern (completing-read "Function: " obarray #'fboundp t))))
|
2003-05-30 23:31:15 +00:00
|
|
|
|
(let ((timer (timer-create)))
|
|
|
|
|
(timer-set-function timer function args)
|
|
|
|
|
(timer-set-idle-time timer secs repeat)
|
2006-08-20 12:16:26 +00:00
|
|
|
|
(timer-activate-when-idle timer t)
|
2003-05-30 23:31:15 +00:00
|
|
|
|
timer))
|
|
|
|
|
|
2005-07-10 17:18:25 +00:00
|
|
|
|
(defvar with-timeout-timers nil
|
|
|
|
|
"List of all timers used by currently pending `with-timeout' calls.")
|
|
|
|
|
|
2003-05-30 23:31:15 +00:00
|
|
|
|
(defmacro with-timeout (list &rest body)
|
|
|
|
|
"Run BODY, but if it doesn't finish in SECONDS seconds, give up.
|
|
|
|
|
If we give up, we run the TIMEOUT-FORMS and return the value of the last one.
|
|
|
|
|
The timeout is checked whenever Emacs waits for some kind of external
|
2005-07-04 01:22:30 +00:00
|
|
|
|
event (such as keyboard input, input from subprocesses, or a certain time);
|
2003-05-30 23:31:15 +00:00
|
|
|
|
if the program loops without waiting in any way, the timeout will not
|
2005-07-04 01:22:30 +00:00
|
|
|
|
be detected.
|
|
|
|
|
\n(fn (SECONDS TIMEOUT-FORMS...) BODY)"
|
2011-10-13 01:18:12 -04:00
|
|
|
|
(declare (indent 1) (debug ((form body) body)))
|
2003-05-30 23:31:15 +00:00
|
|
|
|
(let ((seconds (car list))
|
2011-10-13 01:18:12 -04:00
|
|
|
|
(timeout-forms (cdr list))
|
|
|
|
|
(timeout (make-symbol "timeout")))
|
|
|
|
|
`(let ((-with-timeout-value-
|
|
|
|
|
(catch ',timeout
|
|
|
|
|
(let* ((-with-timeout-timer-
|
|
|
|
|
(run-with-timer ,seconds nil
|
|
|
|
|
(lambda () (throw ',timeout ',timeout))))
|
|
|
|
|
(with-timeout-timers
|
|
|
|
|
(cons -with-timeout-timer- with-timeout-timers)))
|
|
|
|
|
(unwind-protect
|
2012-10-04 14:27:37 -04:00
|
|
|
|
(progn ,@body)
|
2011-10-13 01:18:12 -04:00
|
|
|
|
(cancel-timer -with-timeout-timer-))))))
|
|
|
|
|
;; It is tempting to avoid the `if' altogether and instead run
|
|
|
|
|
;; timeout-forms in the timer, just before throwing `timeout'.
|
|
|
|
|
;; But that would mean that timeout-forms are run in the deeper
|
|
|
|
|
;; dynamic context of the timer, with inhibit-quit set etc...
|
|
|
|
|
(if (eq -with-timeout-value- ',timeout)
|
|
|
|
|
(progn ,@timeout-forms)
|
|
|
|
|
-with-timeout-value-))))
|
2003-05-30 23:31:15 +00:00
|
|
|
|
|
2005-07-10 17:18:25 +00:00
|
|
|
|
(defun with-timeout-suspend ()
|
|
|
|
|
"Stop the clock for `with-timeout'. Used by debuggers.
|
|
|
|
|
The idea is that the time you spend in the debugger should not
|
|
|
|
|
count against these timeouts.
|
|
|
|
|
|
|
|
|
|
The value is a list that the debugger can pass to `with-timeout-unsuspend'
|
|
|
|
|
when it exits, to make these timers start counting again."
|
|
|
|
|
(mapcar (lambda (timer)
|
|
|
|
|
(cancel-timer timer)
|
Improve time stamp handling, and be more consistent about it.
This implements a suggestion made in:
http://lists.gnu.org/archive/html/emacs-devel/2014-10/msg00587.html
Among other things, this means timer.el no longer needs to
autoload the time-date module.
* doc/lispref/os.texi (Time of Day, Time Conversion, Time Parsing)
(Processor Run Time, Time Calculations):
Document the new behavior, plus be clearer about the old behavior.
(Idle Timers): Take advantage of new functionality.
* etc/NEWS: Document the changes.
* lisp/allout-widgets.el (allout-elapsed-time-seconds): Doc fix.
* lisp/arc-mode.el (archive-ar-summarize):
* lisp/calendar/time-date.el (seconds-to-time, days-to-time, time-since):
* lisp/emacs-lisp/timer.el (timer-relative-time, timer-event-handler)
(run-at-time, with-timeout-suspend, with-timeout-unsuspend):
* lisp/net/tramp.el (tramp-time-less-p, tramp-time-subtract):
* lisp/proced.el (proced-time-lessp):
* lisp/timezone.el (timezone-time-from-absolute):
* lisp/type-break.el (type-break-schedule, type-break-time-sum):
Simplify by using new functionality.
* lisp/calendar/cal-dst.el (calendar-next-time-zone-transition):
Do not return time values in obsolete and undocumented (HI . LO)
format; use (HI LO) instead.
* lisp/calendar/time-date.el (with-decoded-time-value):
Treat 'nil' as current time. This is mostly for XEmacs.
(encode-time-value, with-decoded-time-value): Obsolete.
(time-add, time-subtract, time-less-p): Use no-op autoloads, for
XEmacs. Define only if XEmacs, as they're now C builtins in Emacs.
* lisp/ldefs-boot.el: Update to match new time-date.el
* lisp/proced.el: Do not require time-date.
* src/editfns.c (invalid_time): New function.
Use it instead of 'error ("Invalid time specification")'.
(time_add, time_subtract, time_arith, Ftime_add, Ftime_less_p)
(decode_float_time, lisp_to_timespec, lisp_time_struct):
New functions.
(make_time_tail, make_time): Remove. All uses changed to use
new functions or plain list4i.
(disassemble_lisp_time): Return effective length if successful.
Check that LOW is an integer, if it's combined with other components.
(decode_time_components): Decode into struct lisp_time, not
struct timespec, so that we can support a wide set of times
regardless of whether time_t is signed. Decode plain numbers
as seconds since the Epoch, and nil as the current time.
(lisp_time_argument, lisp_seconds_argument, Ffloat_time):
Reimplement in terms of new functions.
(Fencode_time): Just use list2i.
(syms_of_editfns): Add time-add, time-subtract, time-less-p.
* src/keyboard.c (decode_timer): Don't allow the new formats (floating
point or nil) in timers.
* src/systime.h (LO_TIME_BITS): New constant. Use it everywhere in
place of the magic number '16'.
(struct lisp_time): New type.
(decode_time_components): Use it.
(lisp_to_timespec): New decl.
2014-11-16 20:38:15 -08:00
|
|
|
|
(list timer (time-subtract (timer--time timer) nil)))
|
2005-07-10 17:18:25 +00:00
|
|
|
|
with-timeout-timers))
|
|
|
|
|
|
|
|
|
|
(defun with-timeout-unsuspend (timer-spec-list)
|
|
|
|
|
"Restart the clock for `with-timeout'.
|
|
|
|
|
The argument should be a value previously returned by `with-timeout-suspend'."
|
|
|
|
|
(dolist (elt timer-spec-list)
|
|
|
|
|
(let ((timer (car elt))
|
|
|
|
|
(delay (cadr elt)))
|
Improve time stamp handling, and be more consistent about it.
This implements a suggestion made in:
http://lists.gnu.org/archive/html/emacs-devel/2014-10/msg00587.html
Among other things, this means timer.el no longer needs to
autoload the time-date module.
* doc/lispref/os.texi (Time of Day, Time Conversion, Time Parsing)
(Processor Run Time, Time Calculations):
Document the new behavior, plus be clearer about the old behavior.
(Idle Timers): Take advantage of new functionality.
* etc/NEWS: Document the changes.
* lisp/allout-widgets.el (allout-elapsed-time-seconds): Doc fix.
* lisp/arc-mode.el (archive-ar-summarize):
* lisp/calendar/time-date.el (seconds-to-time, days-to-time, time-since):
* lisp/emacs-lisp/timer.el (timer-relative-time, timer-event-handler)
(run-at-time, with-timeout-suspend, with-timeout-unsuspend):
* lisp/net/tramp.el (tramp-time-less-p, tramp-time-subtract):
* lisp/proced.el (proced-time-lessp):
* lisp/timezone.el (timezone-time-from-absolute):
* lisp/type-break.el (type-break-schedule, type-break-time-sum):
Simplify by using new functionality.
* lisp/calendar/cal-dst.el (calendar-next-time-zone-transition):
Do not return time values in obsolete and undocumented (HI . LO)
format; use (HI LO) instead.
* lisp/calendar/time-date.el (with-decoded-time-value):
Treat 'nil' as current time. This is mostly for XEmacs.
(encode-time-value, with-decoded-time-value): Obsolete.
(time-add, time-subtract, time-less-p): Use no-op autoloads, for
XEmacs. Define only if XEmacs, as they're now C builtins in Emacs.
* lisp/ldefs-boot.el: Update to match new time-date.el
* lisp/proced.el: Do not require time-date.
* src/editfns.c (invalid_time): New function.
Use it instead of 'error ("Invalid time specification")'.
(time_add, time_subtract, time_arith, Ftime_add, Ftime_less_p)
(decode_float_time, lisp_to_timespec, lisp_time_struct):
New functions.
(make_time_tail, make_time): Remove. All uses changed to use
new functions or plain list4i.
(disassemble_lisp_time): Return effective length if successful.
Check that LOW is an integer, if it's combined with other components.
(decode_time_components): Decode into struct lisp_time, not
struct timespec, so that we can support a wide set of times
regardless of whether time_t is signed. Decode plain numbers
as seconds since the Epoch, and nil as the current time.
(lisp_time_argument, lisp_seconds_argument, Ffloat_time):
Reimplement in terms of new functions.
(Fencode_time): Just use list2i.
(syms_of_editfns): Add time-add, time-subtract, time-less-p.
* src/keyboard.c (decode_timer): Don't allow the new formats (floating
point or nil) in timers.
* src/systime.h (LO_TIME_BITS): New constant. Use it everywhere in
place of the magic number '16'.
(struct lisp_time): New type.
(decode_time_components): Use it.
(lisp_to_timespec): New decl.
2014-11-16 20:38:15 -08:00
|
|
|
|
(timer-set-time timer (time-add nil delay))
|
2005-07-10 17:18:25 +00:00
|
|
|
|
(timer-activate timer))))
|
|
|
|
|
|
2003-05-30 23:31:15 +00:00
|
|
|
|
(defun y-or-n-p-with-timeout (prompt seconds default-value)
|
|
|
|
|
"Like (y-or-n-p PROMPT), with a timeout.
|
|
|
|
|
If the user does not answer after SECONDS seconds, return DEFAULT-VALUE."
|
|
|
|
|
(with-timeout (seconds default-value)
|
|
|
|
|
(y-or-n-p prompt)))
|
|
|
|
|
|
2009-11-11 06:36:41 +00:00
|
|
|
|
(defconst timer-duration-words
|
2003-05-30 23:31:15 +00:00
|
|
|
|
(list (cons "microsec" 0.000001)
|
|
|
|
|
(cons "microsecond" 0.000001)
|
|
|
|
|
(cons "millisec" 0.001)
|
|
|
|
|
(cons "millisecond" 0.001)
|
|
|
|
|
(cons "sec" 1)
|
|
|
|
|
(cons "second" 1)
|
|
|
|
|
(cons "min" 60)
|
|
|
|
|
(cons "minute" 60)
|
|
|
|
|
(cons "hour" (* 60 60))
|
|
|
|
|
(cons "day" (* 24 60 60))
|
|
|
|
|
(cons "week" (* 7 24 60 60))
|
|
|
|
|
(cons "fortnight" (* 14 24 60 60))
|
|
|
|
|
(cons "month" (* 30 24 60 60)) ; Approximation
|
|
|
|
|
(cons "year" (* 365.25 24 60 60)) ; Approximation
|
|
|
|
|
)
|
2008-11-30 01:01:18 +00:00
|
|
|
|
"Alist mapping temporal words to durations in seconds.")
|
2003-05-30 23:31:15 +00:00
|
|
|
|
|
|
|
|
|
(defun timer-duration (string)
|
|
|
|
|
"Return number of seconds specified by STRING, or nil if parsing fails."
|
|
|
|
|
(let ((secs 0)
|
|
|
|
|
(start 0)
|
|
|
|
|
(case-fold-search t))
|
|
|
|
|
(while (string-match
|
|
|
|
|
"[ \t]*\\([0-9.]+\\)?[ \t]*\\([a-z]+[a-rt-z]\\)s?[ \t]*"
|
|
|
|
|
string start)
|
|
|
|
|
(let ((count (if (match-beginning 1)
|
|
|
|
|
(string-to-number (match-string 1 string))
|
|
|
|
|
1))
|
|
|
|
|
(itemsize (cdr (assoc (match-string 2 string)
|
|
|
|
|
timer-duration-words))))
|
|
|
|
|
(if itemsize
|
|
|
|
|
(setq start (match-end 0)
|
|
|
|
|
secs (+ secs (* count itemsize)))
|
|
|
|
|
(setq secs nil
|
|
|
|
|
start (length string)))))
|
|
|
|
|
(if (= start (length string))
|
|
|
|
|
secs
|
2008-11-30 01:01:18 +00:00
|
|
|
|
(if (string-match-p "\\`[0-9.]+\\'" string)
|
2003-05-30 23:31:15 +00:00
|
|
|
|
(string-to-number string)))))
|
2013-04-10 09:31:35 -04:00
|
|
|
|
|
|
|
|
|
(defun internal-timer-start-idle ()
|
|
|
|
|
"Mark all idle-time timers as once again candidates for running."
|
|
|
|
|
(dolist (timer timer-idle-list)
|
|
|
|
|
(if (timerp timer) ;; FIXME: Why test?
|
|
|
|
|
(setf (timer--triggered timer) nil))))
|
2003-05-30 23:31:15 +00:00
|
|
|
|
|
|
|
|
|
(provide 'timer)
|
|
|
|
|
|
|
|
|
|
;;; timer.el ends here
|