From 24d444a272bd4b42739a1883c4d5f0545dfce58a Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Fri, 5 Apr 2024 15:49:34 -0400 Subject: [PATCH 2/2] lisp: Prefer 'funcall-later' over 'run-with-timer' * lisp/subr.el (do-after-load-evaluation): * lisp/server.el (server-goto-toplevel): * lisp/progmodes/compile.el (compilation-error-properties): * lisp/menu-bar.el (menu-bar-mode): * lisp/jit-lock.el (jit-lock-fontify-now): * lisp/emacs-lisp/edebug.el (edebug-kill-buffer) (edebug-unload-function): Use 'funcall-later' i.s.o 'run-with-timer'. --- lisp/emacs-lisp/edebug.el | 4 ++-- lisp/jit-lock.el | 6 +++--- lisp/menu-bar.el | 6 +++--- lisp/progmodes/compile.el | 4 ++-- lisp/server.el | 2 +- lisp/subr.el | 3 +-- 6 files changed, 12 insertions(+), 13 deletions(-) diff --git a/lisp/emacs-lisp/edebug.el b/lisp/emacs-lisp/edebug.el index b27ffbca908..fc76552312f 100644 --- a/lisp/emacs-lisp/edebug.el +++ b/lisp/emacs-lisp/edebug.el @@ -4023,7 +4023,7 @@ edebug-mode (defun edebug-kill-buffer () "Used on `kill-buffer-hook' when Edebug is operating in a buffer of Lisp code." - (run-with-timer 0 nil #'top-level)) + (funcall-later #'top-level)) ;;; edebug eval list mode @@ -4597,7 +4597,7 @@ edebug-unload-function (unwind-protect (abort-recursive-edit) ;; We still want to run unload-feature to completion - (run-with-idle-timer 0 nil #'(lambda () (unload-feature 'edebug))))) + (funcall-later #'unload-feature 'edebug))) (remove-hook 'called-interactively-p-functions #'edebug--called-interactively-skip) (edebug-uninstall-read-eval-functions) diff --git a/lisp/jit-lock.el b/lisp/jit-lock.el index 05c0bd847b3..14c172c1e6a 100644 --- a/lisp/jit-lock.el +++ b/lisp/jit-lock.el @@ -478,9 +478,9 @@ jit-lock-fontify-now ;; eagerly extend the refontified region with ;; jit-lock-after-change-extend-region-functions. (when (< loose-beg orig-start) - (run-with-timer 0 nil #'jit-lock-force-redisplay - (copy-marker loose-beg) - (copy-marker orig-start))) + (funcall-later #'jit-lock-force-redisplay + (copy-marker loose-beg) + (copy-marker orig-start))) ;; Skip to the end of the fully refontified part. (setq start tight-end))) diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el index 320fabb54cf..7a4de133b74 100644 --- a/lisp/menu-bar.el +++ b/lisp/menu-bar.el @@ -2632,9 +2632,9 @@ menu-bar-mode ;; directly. The minor-mode message "Menu Bar mode disabled" comes ;; after this function returns, overwriting any message we do here. (when (and (called-interactively-p 'interactive) (not menu-bar-mode)) - (run-with-idle-timer 0 nil 'message - (substitute-command-keys - "Menu Bar mode disabled. \ + (funcall-later #'message + (substitute-command-keys + "Menu Bar mode disabled. \ Use \\[menu-bar-mode] to make the menu bar appear.")))) ;;;###autoload diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el index 11d400e145a..952f03d3155 100644 --- a/lisp/progmodes/compile.el +++ b/lisp/progmodes/compile.el @@ -1402,8 +1402,8 @@ compilation-error-properties (when (and compilation-auto-jump-to-next (>= type compilation-skip-threshold)) (kill-local-variable 'compilation-auto-jump-to-next) - (run-with-timer 0 nil 'compilation-auto-jump - (current-buffer) (match-beginning 0))) + (funcall-later #'compilation-auto-jump + (current-buffer) (match-beginning 0))) (compilation-internal-error-properties file line end-line col end-col type fmt rule)))) diff --git a/lisp/server.el b/lisp/server.el index b65053267a6..8e3c1d0a467 100644 --- a/lisp/server.el +++ b/lisp/server.el @@ -1031,7 +1031,7 @@ server-goto-toplevel ;; to open a frame on a new display, we might end up with an unusable ;; frame because input from that display will be blocked (until exiting ;; the minibuffer). Better exit this minibuffer right away. - (run-with-timer 0 nil (lambda () (server-execute-continuation proc))) + (funcall-later #'server-execute-continuation proc) (top-level))) ;; We use various special properties on process objects: diff --git a/lisp/subr.el b/lisp/subr.el index fba70342154..20fdf8deded 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -5981,8 +5981,7 @@ do-after-load-evaluation byte-compile-current-file byte-compile-root-dir))) (byte-compile-warn "%s" msg))) - (noninteractive (funcall fun msg)) ;; No timer will be run! - (t (run-with-idle-timer 0 nil fun msg)))))) + (t (funcall-later fun msg)))))) ;; Finally, run any other hook. (run-hook-with-args 'after-load-functions abs-file)) -- 2.43.0