I just thought of a 3rd solution: modify later-do.el to make it process the task list in batches of 20 or so before waiting.
It's... Well, 20 times-or-so faster! Increasing `later-do-batch' to 100 or more makes it even faster but then Emacs starts stuttering. Let me know what you think. I'll merge this later if that's fine to everyone.
From 8c9183cb188a37981da1a998b5631f811472a8a0 Mon Sep 17 00:00:00 2001 From: Pierre Neidhardt <[email protected]> Date: Sat, 7 Apr 2018 18:53:43 +0530 Subject: [PATCH] lisp/later-do.el: Speed up later-do-list job by batch-processing --- lisp/later-do.el | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/lisp/later-do.el b/lisp/later-do.el index d8222ae..72fcd46 100644 --- a/lisp/later-do.el +++ b/lisp/later-do.el @@ -1,7 +1,7 @@ ;;; later-do.el --- execute lisp code ... later ;; Copyright (C) 2004, 2005, 2006, 2007, 2008, -;; 2009 Free Software Foundation, Inc. +;; 2009, 2018 Free Software Foundation, Inc. ;; Author: Jorgen Schaefer <[email protected]> @@ -28,7 +28,7 @@ ;;; Code: -(defvar later-do-version "0.2emms2 (2005-09-20)" +(defvar later-do-version "0.2emms4 (2018-04-07)" "Version string of later-do.") (defgroup later-do nil @@ -41,6 +41,14 @@ :group 'later-do :type 'number) +(defcustom later-do-batch 20 + "How many functions to process `before waiting `later-do-interval'. +The functions are processed from `later-do-list'. Must be 1 or +greater. Too high a value might make Emacs slower while the +list is being processed." + :group 'later-do + :type 'number) + (defvar later-do-list nil "A list of functions to be called later on.") @@ -63,14 +71,16 @@ executed in the sequence it was added." empty." (if (null later-do-list) (setq later-do-timer nil) - (let ((fun (caar later-do-list)) - (args (cdar later-do-list))) - (setq later-do-list (cdr later-do-list)) + (let (res) (unwind-protect - (apply fun args) - (setq later-do-timer (run-with-timer later-do-interval - nil - 'later-do-timer)))))) + (dotimes (b (min later-do-batch (length later-do-list)) res) + (let ((fun (caar later-do-list)) + (args (cdar later-do-list))) + (setq later-do-list (cdr later-do-list)) + (setq res (apply fun args))))) + (setq later-do-timer (run-with-timer later-do-interval + nil + 'later-do-timer))))) (provide 'later-do) ;;; later-do.el ends here -- 2.16.3
-- Pierre Neidhardt
signature.asc
Description: PGP signature
_______________________________________________ Emms-help mailing list [email protected] https://lists.gnu.org/mailman/listinfo/emms-help
