From 155ddde4dd3f6246814ab76bc2f54f4d571bbd15 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Tue, 18 Oct 2022 18:43:50 -0400 Subject: [PATCH] (sit-for): Add compiler-macro to warn about obsolete calling convention * lisp/subr.el (sit-for): Add compiler-macro. * lisp/eshell/esh-util.el (eshell-redisplay): * lisp/play/zone.el (zone, zone-pgm-jitter, zone-pgm-whack-chars): (zone-remove-text): Avoid obsolete calling convention. --- lisp/eshell/esh-util.el | 2 +- lisp/play/zone.el | 8 ++++---- lisp/subr.el | 9 ++++++++- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/lisp/eshell/esh-util.el b/lisp/eshell/esh-util.el index 9b464a0a137..f47373c115f 100644 --- a/lisp/eshell/esh-util.el +++ b/lisp/eshell/esh-util.el @@ -455,7 +455,7 @@ list." ;; runs while point is in the minibuffer and the users attempt ;; to use completion. Don't ask me. (condition-case nil - (sit-for 0 0) + (sit-for 0) (error nil))) (defun eshell-read-passwd-file (file) diff --git a/lisp/play/zone.el b/lisp/play/zone.el index 5ea5bbc9267..e3a9507f1cc 100644 --- a/lisp/play/zone.el +++ b/lisp/play/zone.el @@ -139,7 +139,7 @@ run a specific program. The program must be a member of (untabify (point-min) (point-max)) (set-window-start (selected-window) (point-min)) (set-window-point (selected-window) wp) - (sit-for 0 500) + (sit-for 0.500) (let ((ct (and f (frame-parameter f 'cursor-type))) (show-trailing-whitespace nil) restore) @@ -249,7 +249,7 @@ run a specific program. The program must be a member of (while (not (input-pending-p)) (funcall (elt ops (random (length ops)))) (goto-char (point-min)) - (sit-for 0 10)))) + (sit-for 0.01)))) ;;;; whacking chars @@ -262,7 +262,7 @@ run a specific program. The program must be a member of (aset tbl i (+ 48 (random (- 123 48)))) (setq i (1+ i))) (translate-region (point-min) (point-max) tbl) - (sit-for 0 2))))) + (sit-for 0.002))))) (put 'zone-pgm-whack-chars 'wc-tbl (let ((tbl (make-string 128 ?x)) @@ -290,7 +290,7 @@ run a specific program. The program must be a member of (delete-char 1) (insert " "))) (forward-char 1)))) - (sit-for 0 2)))) + (sit-for 0.002)))) (defun zone-pgm-dissolve () (zone-remove-text) diff --git a/lisp/subr.el b/lisp/subr.el index 08dfe7aa430..e49c22158f9 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -3270,7 +3270,14 @@ An obsolete, but still supported form is where the optional arg MILLISECONDS specifies an additional wait period, in milliseconds; this was useful when Emacs was built without floating point support." - (declare (advertised-calling-convention (seconds &optional nodisp) "22.1")) + (declare (advertised-calling-convention (seconds &optional nodisp) "22.1") + (compiler-macro + (lambda (form) + (if (not (or (numberp nodisp) obsolete)) form + (macroexp-warn-and-return + "Obsolete calling convention for 'sit-for'" + `(,(car form) (+ ,seconds (/ (or ,nodisp 0) 1000.0)) ,obsolete) + '(obsolete sit-for)))))) ;; This used to be implemented in C until the following discussion: ;; https://lists.gnu.org/r/emacs-devel/2006-07/msg00401.html ;; Then it was moved here using an implementation based on an idle timer, -- 2.39.5