From: Lars Ingebrigtsen Date: Mon, 25 Oct 2021 15:10:34 +0000 (+0200) Subject: Change the with-delayed-message syntax to allow future extensibility X-Git-Tag: emacs-29.0.90~3671^2~420 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=9ce0008edd3be96bf1271d770b8e65c56a334b1c;p=emacs.git Change the with-delayed-message syntax to allow future extensibility * doc/lispref/display.texi (Progress): Document it. * lisp/subr.el (with-delayed-message): Change the syntax to allow future extensibility. * lisp/net/eww.el (eww-display-html): Use it. --- diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi index 6f95728e315..cc9ca28bf02 100644 --- a/doc/lispref/display.texi +++ b/doc/lispref/display.texi @@ -561,13 +561,13 @@ You can rewrite the previous example with this macro as follows: @end example @end defmac -@defmac with-delayed-message timeout message body@dots{} +@defmac with-delayed-message (timeout message) body@dots{} Sometimes it's unclear whether an operation will take a long time to execute or not, or it can be inconvenient to implement a progress reporter. This macro can be used in those situations. @lisp -(with-delayed-message 2 (format "Gathering data for %s" entry) +(with-delayed-message (2 (format "Gathering data for %s" entry)) (setq data (gather-data entry))) @end lisp diff --git a/lisp/net/eww.el b/lisp/net/eww.el index e0bc17b5a5d..74d3788116d 100644 --- a/lisp/net/eww.el +++ b/lisp/net/eww.el @@ -694,7 +694,7 @@ The renaming scheme is performed in accordance with (meta . eww-tag-meta) (a . eww-tag-a))))) (erase-buffer) - (with-delayed-message 2 "Rendering HTML..." + (with-delayed-message (2 "Rendering HTML...") (shr-insert-document document)) (cond (point diff --git a/lisp/subr.el b/lisp/subr.el index 9acc79923c9..86460d9da6c 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -6723,12 +6723,14 @@ as the variable documentation string. (define-keymap--define (list ,@(nreverse opts) ,@defs)) ,@(and doc (list doc))))) -(defmacro with-delayed-message (timeout message &rest body) +(defmacro with-delayed-message (args &rest body) "Like `progn', but display MESSAGE if BODY takes longer than TIMEOUT seconds. The MESSAGE form will be evaluated immediately, but the resulting -string will be displayed only if BODY takes longer than TIMEOUT seconds." - (declare (indent 2)) - `(funcall-with-delayed-message ,timeout ,message +string will be displayed only if BODY takes longer than TIMEOUT seconds. + +\(fn (timeout message) &rest body)" + (declare (indent 1)) + `(funcall-with-delayed-message ,(car args) ,(cadr args) (lambda () ,@body)))