From unknown Wed Aug 20 06:39:20 2025 X-Loop: help-debbugs@gnu.org Subject: bug#31696: 27.0.50; dotimes-with-progress-reporter: Polimorphic 2nd argument Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: monnier@iro.umontreal.ca, bug-gnu-emacs@gnu.org Resent-Date: Sun, 03 Jun 2018 13:17:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 31696 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 31696@debbugs.gnu.org Cc: stefan monnier X-Debbugs-Original-To: bug-gnu-emacs@gnu.org X-Debbugs-Original-Xcc: stefan monnier Received: via spool by submit@debbugs.gnu.org id=B.152803178120467 (code B ref -1); Sun, 03 Jun 2018 13:17:02 +0000 Received: (at submit) by debbugs.gnu.org; 3 Jun 2018 13:16:21 +0000 Received: from localhost ([127.0.0.1]:59876 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fPSrt-0005K2-1h for submit@debbugs.gnu.org; Sun, 03 Jun 2018 09:16:21 -0400 Received: from eggs.gnu.org ([208.118.235.92]:49780) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fPSrr-0005Jm-9A for submit@debbugs.gnu.org; Sun, 03 Jun 2018 09:16:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fPSrk-0003Ep-Qj for submit@debbugs.gnu.org; Sun, 03 Jun 2018 09:16:13 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM, T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:36600) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fPSrk-0003El-My for submit@debbugs.gnu.org; Sun, 03 Jun 2018 09:16:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40735) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fPSrh-0000bf-Sd for bug-gnu-emacs@gnu.org; Sun, 03 Jun 2018 09:16:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fPSrd-0003Df-TR for bug-gnu-emacs@gnu.org; Sun, 03 Jun 2018 09:16:09 -0400 Received: from mail-pg0-x22d.google.com ([2607:f8b0:400e:c05::22d]:36976) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fPSrd-0003DO-Lg for bug-gnu-emacs@gnu.org; Sun, 03 Jun 2018 09:16:05 -0400 Received: by mail-pg0-x22d.google.com with SMTP id a13-v6so13239660pgu.4 for ; Sun, 03 Jun 2018 06:16:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version; bh=+8IIT13MmBaO7qqSc9CE9Xk097uTI2Ah97WGjDaSlR8=; b=AVeaSrGNj1/vim47XzxmJYcrqGGePzETMkS0hOkc4Edf1I/8z3r6oGuI+qZUAxs8Bh pMoHMIZsYOAtb/zUhX+Z6gaS/oiHwmFdHLul7htWyhRIIcoYH8Xc75m5CVUk2I8pA2ru B0TxlxamXd1HHGhNdlyJODl4Te42p+rUX14AVoCTenwQVCOKECKlan1z4WspmqiBjq9E qrAfvnP3Sdi9zl06C21Q0d/pKZYlRU2iL08o+UnDTntf/htJYhxp+/JZwV9hChMKHwVz c+bjUyv44j/edP5UmwHr+LPRwYqNcs19Vj4ZnZ4p7qVENCDaEKb5GqEcq5Kzx4D1pgQD KkKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version; bh=+8IIT13MmBaO7qqSc9CE9Xk097uTI2Ah97WGjDaSlR8=; b=etE6t0C5zgY2oixus++9JwtEjT3dgszLOqeFXwj467R1lYV6XgtPT7Z3C0pRDc+DLD da4IBT7I2V+j8ghqEX86AfhgCm62iA7c1w2OHyhohSZy8TLsafLiJdr8fyNG6D07Qsxa QnwezBn2NYpMLIOEdhwISI2MVzvY78BXF5oA9/mnajHFxpNlPpjjcTYWMHEOUukP40yq E+pgbWX7fCHdQsR52fo4XQW4kvVvYrlOyZpwVlYkRfG8CCpyaih0fF+BZRukU8P1uhoP VS6/suxJF9EmRECZREtm43nzT7wN4AQ+NrwHxXiqsxlqPkI/j68lAb8tAuT1yGHdOT1y R7Yg== X-Gm-Message-State: ALKqPwdCFBguFOX38Sr1W0h3eVg4n8AHt1CZGxrvzkX2iYeaSRTavQ+y hggxtOj+5AkerIBSl5nIjr4T7g== X-Google-Smtp-Source: ADUXVKIqI2ABYlTAcGqSeHEUQ0i6iva8OjDoa+S6CnLxBKgE5d/pbMSid+uisVAZadgp1qparlIZxw== X-Received: by 2002:a62:ea1a:: with SMTP id t26-v6mr17756803pfh.117.1528031764274; Sun, 03 Jun 2018 06:16:04 -0700 (PDT) Received: from calancha-pc (228.225.128.101.dy.bbexcite.jp. [101.128.225.228]) by smtp.gmail.com with ESMTPSA id z129-v6sm70711534pfb.108.2018.06.03.06.16.02 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 03 Jun 2018 06:16:03 -0700 (PDT) From: Tino Calancha Date: Sun, 03 Jun 2018 22:15:56 +0900 Message-ID: <874lik57ub.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) Severity: Wishlist X-Debbugs-Cc: Stefan Monnier The second arg might be a string or a progress reporter object; the latter is useful if the programmer wish to specify the optional parameters of the reporter. --8<-----------------------------cut here---------------start------------->8--- commit d4d07b0d9a444cc925d0c1c6fbcc155f9709fbe9 Author: Tino Calancha Date: Sun Jun 3 22:06:01 2018 +0900 dotimes-with-progress-reporter: Polimorphic 2nd argument * lisp/subr.el (dotimes-with-progress-reporter): Allow 2nd arg to be a string or a progress reporter (Bug#31696). * doc/lispref/display.texi (node Progress): Update manual. diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi index ce7ec3ac10..8591fa8cef 100644 --- a/doc/lispref/display.texi +++ b/doc/lispref/display.texi @@ -469,7 +469,7 @@ Progress Secondly, @samp{done} is more explicit. @end defun -@defmac dotimes-with-progress-reporter (var count [result]) message body@dots{} +@defmac dotimes-with-progress-reporter (var count [result]) reporter-or-message body@dots{} This is a convenience macro that works the same way as @code{dotimes} does, but also reports loop progress using the functions described above. It allows you to save some typing. @@ -483,6 +483,18 @@ Progress "Collecting some mana for Emacs..." (sit-for 0.01)) @end example + + +The second argument @code{reporter-or-message} might be a progress +reporter object. This is useful if you want to specify the optional +arguments in @code{make-progress-reporter}. +For instance, you can write previous example as follows: +@example +(dotimes-with-progress-reporter + (k 500) + (make-progress-reporter "Collecting some mana for Emacs..." 0 500 0 1 1.5) + (sit-for 0.01)) +@end example @end defmac @node Logging Messages diff --git a/lisp/subr.el b/lisp/subr.el index 914112ccef..a1b2556239 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -5013,32 +5013,32 @@ progress-reporter-done "Print reporter's message followed by word \"done\" in echo area." (message "%sdone" (aref (cdr reporter) 3))) -(defmacro dotimes-with-progress-reporter (spec message &rest body) +(defmacro dotimes-with-progress-reporter (spec reporter-or-message &rest body) "Loop a certain number of times and report progress in the echo area. Evaluate BODY with VAR bound to successive integers running from 0, inclusive, to COUNT, exclusive. Then evaluate RESULT to get the return value (nil if RESULT is omitted). -At each iteration MESSAGE followed by progress percentage is -printed in the echo area. After the loop is finished, MESSAGE -followed by word \"done\" is printed. This macro is a -convenience wrapper around `make-progress-reporter' and friends. +REPORTER-OR-MESSAGE is a progress reporter object or a string. In the latter +case, use this string to create a progress reporter. + +At each iteration, print the reporter message followed by progress +percentage in the echo area. After the loop is finished, +print the reporter message followed by word \"done\". + +This macro is a convenience wrapper around `make-progress-reporter' and friends. \(fn (VAR COUNT [RESULT]) MESSAGE BODY...)" (declare (indent 2) (debug ((symbolp form &optional form) form body))) - (let ((temp (make-symbol "--dotimes-temp--")) - (temp2 (make-symbol "--dotimes-temp2--")) - (start 0) - (end (nth 1 spec))) - `(let ((,temp ,end) - (,(car spec) ,start) - (,temp2 (make-progress-reporter ,message ,start ,end))) - (while (< ,(car spec) ,temp) - ,@body - (progress-reporter-update ,temp2 - (setq ,(car spec) (1+ ,(car spec))))) - (progress-reporter-done ,temp2) - nil ,@(cdr (cdr spec))))) + (let ((prep (make-symbol "--dotimes-prep--"))) + `(let ((,prep ,reporter-or-message)) + (when (stringp ,prep) + (setq ,prep (make-progress-reporter ,prep 0 ,(cadr spec)))) + (dotimes ,spec + ,@body + (progress-reporter-update ,prep (1+ ,(car spec)))) + (progress-reporter-done ,prep) + (or ,@(cdr (cdr spec)) nil)))) ;;;; Comparing version strings. --8<-----------------------------cut here---------------end--------------->8--- In GNU Emacs 27.0.50 (build 78, x86_64-pc-linux-gnu, GTK+ Version 3.22.11) of 2018-06-03 built on calancha-pc Repository revision: e75c57f10ee9418599398361b0676f48d265fb12 From unknown Wed Aug 20 06:39:20 2025 X-Loop: help-debbugs@gnu.org Subject: bug#31696: 27.0.50; dotimes-with-progress-reporter: Polimorphic 2nd argument Resent-From: Noam Postavsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 03 Jun 2018 13:41:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 31696 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Tino Calancha Cc: 31696@debbugs.gnu.org, stefan monnier Received: via spool by 31696-submit@debbugs.gnu.org id=B31696.152803324622948 (code B ref 31696); Sun, 03 Jun 2018 13:41:01 +0000 Received: (at 31696) by debbugs.gnu.org; 3 Jun 2018 13:40:46 +0000 Received: from localhost ([127.0.0.1]:59890 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fPTFW-0005y4-Lz for submit@debbugs.gnu.org; Sun, 03 Jun 2018 09:40:46 -0400 Received: from mail-io0-f174.google.com ([209.85.223.174]:43851) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fPTFV-0005xs-Cl for 31696@debbugs.gnu.org; Sun, 03 Jun 2018 09:40:45 -0400 Received: by mail-io0-f174.google.com with SMTP id t6-v6so16385268iob.10 for <31696@debbugs.gnu.org>; Sun, 03 Jun 2018 06:40:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=FLm3GkI+mUS15hvQXgJ5nmgfSRFghG97SX33CGGnu/I=; b=ip2M3DbszPNje4CUsMqZiG7nmmi7WAKS265c580bbX69naXCVwXMBXvgbbklV41VKA mBiwcvCJ2gPhBmIl8biZa9+fQ0eiL4GIKnwRZB/ef03irhyRBuNyxDonkY1/uF++ZI6G ZvagaDipcpKDdnaVTFegUqe1ab1uE59fkSngGgYek6vL9tWpMga8qf5y6ijTxS1TT/eG GlFblglPT1EiDXlkiptxrS9B8lLzZep1tQ+VihSzJIBLwO/37BEL9yqiH1Grbt+xWoDy WifjCBf9KSrpXAwp2RwItaphxTtkSaRTTV2X75r9G3k4spuARzV/zZ4cear6oDL6Ie6E MyTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=FLm3GkI+mUS15hvQXgJ5nmgfSRFghG97SX33CGGnu/I=; b=dEZT/Lnj3Uj4EkU4Gpdgl30Qt/5GUUWIsZGAW+m3t9DDMH8io5B+EhzV0TkO11tndv qNZ65NCNcpD7Qq8izqQzxzR7O4akMajhISBhkt1E93BA1GUWA6UUXl4S2NA+kjtlqIVa I0Y1UhflMb6SvXMmOT2QmwxxacPbdTgIKNi9vXRF70duLLgp4SWHa6c82Hl5sjdTR4C6 PoKnuErZqwYAg9aDrpqI7fD3qJdNWWqAZZodnuMu/jVrb/ghxDa5UFOnZnYdyWjOjLIF DMMw/UdH6pxYOHXFLrf+q6caUViDCIFnMtaJe3A5qbh9URaiw/k9WxO82NDBFbMbdF2i 0Yjg== X-Gm-Message-State: APt69E0X+DBX6gtrzXnYvhlnfxEHK2jBSzljHuuvCjJinBaKP3HaN0x5 BNI1T7cuRhiEBtfeoxrXZUI= X-Google-Smtp-Source: ADUXVKIBb1M0+t8Xptkqq/QBm4jwgDp8FA/hUnSU/R2uneDtnJxHUQVfrj4POU/x4KnYo4iSATG5tw== X-Received: by 2002:a6b:28c6:: with SMTP id o189-v6mr7144071ioo.149.1528033239882; Sun, 03 Jun 2018 06:40:39 -0700 (PDT) Received: from zebian (cbl-45-2-119-34.yyz.frontiernetworks.ca. [45.2.119.34]) by smtp.googlemail.com with ESMTPSA id f72-v6sm3797474iof.14.2018.06.03.06.40.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 03 Jun 2018 06:40:39 -0700 (PDT) From: Noam Postavsky References: <874lik57ub.fsf@gmail.com> Date: Sun, 03 Jun 2018 09:40:37 -0400 In-Reply-To: <874lik57ub.fsf@gmail.com> (Tino Calancha's message of "Sun, 03 Jun 2018 22:15:56 +0900") Message-ID: <87vab07zu2.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Tino Calancha writes: > dotimes-with-progress-reporter: Polimorphic 2nd argument Polymorphic with a "y". > +(defmacro dotimes-with-progress-reporter (spec reporter-or-message &rest body) > + (let ((prep (make-symbol "--dotimes-prep--"))) > + `(let ((,prep ,reporter-or-message)) > + (when (stringp ,prep) > + (setq ,prep (make-progress-reporter ,prep 0 ,(cadr spec)))) > + (dotimes ,spec The (cadr spec) expression would be evaluated twice. From unknown Wed Aug 20 06:39:20 2025 X-Loop: help-debbugs@gnu.org Subject: bug#31696: 27.0.50; dotimes-with-progress-reporter: Polimorphic 2nd argument Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 03 Jun 2018 13:52:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 31696 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Noam Postavsky Cc: 31696@debbugs.gnu.org, stefan monnier Received: via spool by 31696-submit@debbugs.gnu.org id=B31696.152803390723893 (code B ref 31696); Sun, 03 Jun 2018 13:52:01 +0000 Received: (at 31696) by debbugs.gnu.org; 3 Jun 2018 13:51:47 +0000 Received: from localhost ([127.0.0.1]:59894 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fPTQA-0006DI-Mw for submit@debbugs.gnu.org; Sun, 03 Jun 2018 09:51:46 -0400 Received: from mail-pl0-f49.google.com ([209.85.160.49]:42790) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fPTQ8-0006D5-4Q for 31696@debbugs.gnu.org; Sun, 03 Jun 2018 09:51:44 -0400 Received: by mail-pl0-f49.google.com with SMTP id w17-v6so2178228pll.9 for <31696@debbugs.gnu.org>; Sun, 03 Jun 2018 06:51:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=8EzLqtu/ON88Zom482XGaOBPmnSrN8QroGa8TbIaqZA=; b=odWMg/iF+nZnD9mdsvsNp+n0hrXA3WG6Pq/W04eZAnBBftoLGwPB/+Np6ZVDSYBC1Q YDfV6MwfuJBqjH1+pn2cVnaGtaQFPvvjugHk+IV4fNCUH+b5j0EMyLVsTn1ElRy8OvgL upV8VMoJ6neNmFVImPF6hbeacpjVbo1kBe4WLK7egsG6LRFnKQhHkN+W1Z18wx0wRCWw GxQNRkiT/JyIIybAPp19dfpUCn3nSgsG+J27pHXkwXcTd7X7tOGwS27P6h7yYBFNTEqy r9GWSaw+Vt7ktmC4/1fFha5RaZB52QfcnWAWwL2eQlP8l6NdUbQNMoMK+s251PJZX6Pn xzSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=8EzLqtu/ON88Zom482XGaOBPmnSrN8QroGa8TbIaqZA=; b=NGimZLi65tBOUB8CtAPvYxwtZW2cW0It/8LjdW4nW6ynftlgFxSFAU7t7SPLW4rhcK hN+3ZefJjHgsRe8yFmU3BJNngkbgat8Vh2Rr40f4ERAziPUHMF2cBmM4TV0pItQdLcLr 35ibBcOcWxpuotvIS047fL10+r0A5kXHWFkXidDio0soxJdfGiNzeoVquLItUSOikvZa eBxN3FAJUbmKnhpN1Z1st8/c8pePSI7QAjMIKrEJOZQt5G5XgHshMxvKWwFohfoU+BkH fDKw6Bt7GNz5cGIjib6hPQjAV+hPLadIT0ZI1pi/SOoVSrP/4y7q9TAdD+2x6oCv1otY Favg== X-Gm-Message-State: ALKqPwd9g3znysnouv7Erq+YWuVz1OsKIDl4yWqcjxRYNTw38jWTO1DZ d7uyxQg+m98rqS65CBNLGao= X-Google-Smtp-Source: ADUXVKLbpkCw/cGCOdkuEXS16AaWZhw0eqpOVSD+rFM6kWJmVBkkUxXaG76Z+tOnas50anwppOOE9Q== X-Received: by 2002:a17:902:52ee:: with SMTP id a101-v6mr18221548pli.131.1528033898232; Sun, 03 Jun 2018 06:51:38 -0700 (PDT) Received: from calancha-pc (228.225.128.101.dy.bbexcite.jp. [101.128.225.228]) by smtp.gmail.com with ESMTPSA id a10-v6sm28258126pfg.107.2018.06.03.06.51.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 03 Jun 2018 06:51:37 -0700 (PDT) From: Tino Calancha References: <874lik57ub.fsf@gmail.com> <87vab07zu2.fsf@gmail.com> Date: Sun, 03 Jun 2018 22:51:34 +0900 In-Reply-To: <87vab07zu2.fsf@gmail.com> (Noam Postavsky's message of "Sun, 03 Jun 2018 09:40:37 -0400") Message-ID: <87y3fw3rmh.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Noam Postavsky writes: > Tino Calancha writes: > >> dotimes-with-progress-reporter: Polimorphic 2nd argument > > Polymorphic with a "y". Thank you :-) >> +(defmacro dotimes-with-progress-reporter (spec reporter-or-message &rest body) > >> + (let ((prep (make-symbol "--dotimes-prep--"))) >> + `(let ((,prep ,reporter-or-message)) >> + (when (stringp ,prep) >> + (setq ,prep (make-progress-reporter ,prep 0 ,(cadr spec)))) >> + (dotimes ,spec > > The (cadr spec) expression would be evaluated twice. Ohhh, you are right. Thank you! I will add another variable. Here is the updated patch: --8<-----------------------------cut here---------------start------------->8--- commit fd7412a31acb16a361cdbda6080954de6241cf0f Author: Tino Calancha Date: Sun Jun 3 22:47:47 2018 +0900 dotimes-with-progress-reporter: Polymorphic 2nd argument * lisp/subr.el (dotimes-with-progress-reporter): Allow 2nd arg to be a string or a progress reporter (Bug#31696). * doc/lispref/display.texi (node Progress): Update manual. diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi index ce7ec3ac10..8591fa8cef 100644 --- a/doc/lispref/display.texi +++ b/doc/lispref/display.texi @@ -469,7 +469,7 @@ Progress Secondly, @samp{done} is more explicit. @end defun -@defmac dotimes-with-progress-reporter (var count [result]) message body@dots{} +@defmac dotimes-with-progress-reporter (var count [result]) reporter-or-message body@dots{} This is a convenience macro that works the same way as @code{dotimes} does, but also reports loop progress using the functions described above. It allows you to save some typing. @@ -483,6 +483,18 @@ Progress "Collecting some mana for Emacs..." (sit-for 0.01)) @end example + + +The second argument @code{reporter-or-message} might be a progress +reporter object. This is useful if you want to specify the optional +arguments in @code{make-progress-reporter}. +For instance, you can write previous example as follows: +@example +(dotimes-with-progress-reporter + (k 500) + (make-progress-reporter "Collecting some mana for Emacs..." 0 500 0 1 1.5) + (sit-for 0.01)) +@end example @end defmac @node Logging Messages diff --git a/lisp/subr.el b/lisp/subr.el index 914112ccef..62b9681f34 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -5013,32 +5013,34 @@ progress-reporter-done "Print reporter's message followed by word \"done\" in echo area." (message "%sdone" (aref (cdr reporter) 3))) -(defmacro dotimes-with-progress-reporter (spec message &rest body) +(defmacro dotimes-with-progress-reporter (spec reporter-or-message &rest body) "Loop a certain number of times and report progress in the echo area. Evaluate BODY with VAR bound to successive integers running from 0, inclusive, to COUNT, exclusive. Then evaluate RESULT to get the return value (nil if RESULT is omitted). -At each iteration MESSAGE followed by progress percentage is -printed in the echo area. After the loop is finished, MESSAGE -followed by word \"done\" is printed. This macro is a -convenience wrapper around `make-progress-reporter' and friends. +REPORTER-OR-MESSAGE is a progress reporter object or a string. In the latter +case, use this string to create a progress reporter. + +At each iteration, print the reporter message followed by progress +percentage in the echo area. After the loop is finished, +print the reporter message followed by word \"done\". + +This macro is a convenience wrapper around `make-progress-reporter' and friends. \(fn (VAR COUNT [RESULT]) MESSAGE BODY...)" (declare (indent 2) (debug ((symbolp form &optional form) form body))) - (let ((temp (make-symbol "--dotimes-temp--")) - (temp2 (make-symbol "--dotimes-temp2--")) - (start 0) - (end (nth 1 spec))) - `(let ((,temp ,end) - (,(car spec) ,start) - (,temp2 (make-progress-reporter ,message ,start ,end))) - (while (< ,(car spec) ,temp) - ,@body - (progress-reporter-update ,temp2 - (setq ,(car spec) (1+ ,(car spec))))) - (progress-reporter-done ,temp2) - nil ,@(cdr (cdr spec))))) + (let ((prep (make-symbol "--dotimes-prep--")) + ((end (make-symbol "--dotimes-end--")))) + `(let ((,prep ,reporter-or-message) + (,end ,(cadr spec))) + (when (stringp ,prep) + (setq ,prep (make-progress-reporter ,prep 0 ,end))) + (dotimes ,spec + ,@body + (progress-reporter-update ,prep (1+ ,(car spec)))) + (progress-reporter-done ,prep) + (or ,@(cdr (cdr spec)) nil)))) ;;;; Comparing version strings. --8<-----------------------------cut here---------------end--------------->8--- From unknown Wed Aug 20 06:39:20 2025 X-Loop: help-debbugs@gnu.org Subject: bug#31696: 27.0.50; dotimes-with-progress-reporter: Polimorphic 2nd argument Resent-From: Noam Postavsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 03 Jun 2018 14:04:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 31696 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Tino Calancha Cc: 31696@debbugs.gnu.org, stefan monnier Received: via spool by 31696-submit@debbugs.gnu.org id=B31696.152803458325399 (code B ref 31696); Sun, 03 Jun 2018 14:04:02 +0000 Received: (at 31696) by debbugs.gnu.org; 3 Jun 2018 14:03:03 +0000 Received: from localhost ([127.0.0.1]:60415 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fPTb5-0006bb-7M for submit@debbugs.gnu.org; Sun, 03 Jun 2018 10:03:03 -0400 Received: from mail-io0-f172.google.com ([209.85.223.172]:35394) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fPTb3-0006b5-Sf for 31696@debbugs.gnu.org; Sun, 03 Jun 2018 10:03:02 -0400 Received: by mail-io0-f172.google.com with SMTP id u4-v6so11277420iof.2 for <31696@debbugs.gnu.org>; Sun, 03 Jun 2018 07:03:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=kkaRl7GGswu8wQiLKawBBJqQkmtrTNJffoOyWQUSnjs=; b=kzu9+0LvmVMsu7AoGr5XYuYuQuL7N7FYiqdamDAWlTqAdkco3rE2wshPLkzAL4X8yv s+hgDIlycn+3hY0EyqGCBeyrSiRAg9AwotYlfxi/Lool8+gjzBrq8Eie258Rk3FvPxXK URMESgAG7TSxdeSk2mKZtzAMakeVYM6VcyA2kMTBcexv6Tw8oLUNb0ARo90hkcJUHigO VBvD8N99/W+TnriQlINYWC6z02eXS+NzSoVNYTTiFfWk5/xZN+oTZw/2dfN5Py0cj6p+ szLHqzXLvNJKMTjV7pT2q+imYuK8z1MCoxg2wekrVN5XLVe1SfQUqYbaX44tBz365MMS yjDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=kkaRl7GGswu8wQiLKawBBJqQkmtrTNJffoOyWQUSnjs=; b=p0LYBeCoVEeGGDiDmrpceXHUJ61cogRdm4DOArKf7IQnw2l0/D6rtlqEdHuXjS/wl5 X5d8J2+m8Qi17l3dxF+ywkmJZE7PhoLDHk7g8t/ZsmH4k5moTrRlBkZEbT7s7+f32GQY 0YkdDMJ/CrpJClZRPMRg4TPLlaO9qSLPS2cKC+8m1vitIfXPsa9RUX0hYp9OX8JzvNh6 QcCmhPGknOokzMpZ+dNJUdqvM9ZGJEU1jpk8cGsLgSug8MdIgTqaWNX910qS1dR1VrJJ gI4g7MUwhBMnKODSRnwtoMht3w1vLgmvLYtAc1JYEg/5WQmbbTJF9vWRwVrAnfjEGpub E4MQ== X-Gm-Message-State: APt69E1GGvYZ8qFBZ+TwoZYUvdwcTxtKp9pol9yakx1nU8jkxCZQmTiU 9AimaJRyxTP3guVRposR2cs= X-Google-Smtp-Source: ADUXVKLi8tFcZDqghq+Z0BR+tcZ1LFdlAnqA0jYNmiosG9+azG4YEEd734YDTO0nJUSUqeLRgyG2Zw== X-Received: by 2002:a6b:150:: with SMTP id 77-v6mr16503528iob.138.1528034576377; Sun, 03 Jun 2018 07:02:56 -0700 (PDT) Received: from zebian (cbl-45-2-119-34.yyz.frontiernetworks.ca. [45.2.119.34]) by smtp.googlemail.com with ESMTPSA id p20-v6sm1542375itf.4.2018.06.03.07.02.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 03 Jun 2018 07:02:55 -0700 (PDT) From: Noam Postavsky References: <874lik57ub.fsf@gmail.com> <87vab07zu2.fsf@gmail.com> <87y3fw3rmh.fsf@gmail.com> Date: Sun, 03 Jun 2018 10:02:54 -0400 In-Reply-To: <87y3fw3rmh.fsf@gmail.com> (Tino Calancha's message of "Sun, 03 Jun 2018 22:51:34 +0900") Message-ID: <87sh647ysx.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.8 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.8 (-) Tino Calancha writes: > +(defmacro dotimes-with-progress-reporter (spec reporter-or-message &rest body) > + (let ((prep (make-symbol "--dotimes-prep--")) > + ((end (make-symbol "--dotimes-end--")))) > + `(let ((,prep ,reporter-or-message) > + (,end ,(cadr spec))) > + (when (stringp ,prep) > + (setq ,prep (make-progress-reporter ,prep 0 ,end))) > + (dotimes ,spec That's still going to evaluate (cadr spec) twice. You need to change the spec passed to `dotimes' so that it also uses `end'. From unknown Wed Aug 20 06:39:20 2025 X-Loop: help-debbugs@gnu.org Subject: bug#31696: 27.0.50; dotimes-with-progress-reporter: Polimorphic 2nd argument Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 03 Jun 2018 14:10:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 31696 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Noam Postavsky Cc: 31696@debbugs.gnu.org, stefan monnier , Tino Calancha Received: via spool by 31696-submit@debbugs.gnu.org id=B31696.152803496925941 (code B ref 31696); Sun, 03 Jun 2018 14:10:02 +0000 Received: (at 31696) by debbugs.gnu.org; 3 Jun 2018 14:09:29 +0000 Received: from localhost ([127.0.0.1]:60419 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fPThJ-0006kL-0o for submit@debbugs.gnu.org; Sun, 03 Jun 2018 10:09:29 -0400 Received: from mail-pf0-f179.google.com ([209.85.192.179]:35986) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fPThH-0006k8-CJ for 31696@debbugs.gnu.org; Sun, 03 Jun 2018 10:09:27 -0400 Received: by mail-pf0-f179.google.com with SMTP id a12-v6so1068774pfi.3 for <31696@debbugs.gnu.org>; Sun, 03 Jun 2018 07:09:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=yWmihMqfsSf9BAfab3RhAePc4yFFVM+q8/40vWOWekE=; b=Bo4VhV8yys/7g7xaCupg63kPB2dY3z9R74BVu22bDiuFKnYUHjtJ/8uvEQLrIKO2Sk i3+8hQSPQZp1yOhVKHXXXlLnYx07+i1LqyNrPCoxuPKqR242nETSKPXISQ6kf7uK7RzR bb68swH04yHY22JXmT9brIottcEAyTcmewpiMZOMMcI66eS4FyLFr4J6Vb3DhOqEZOiC G84UKAsEk1YVuyuGvG40nuONrLjm3omc5X6JCM3FwjWTDVA937GVJTGvMTNvR/bYqo5r 3C8fSJGZhExrM7JFueCD3gFciCkLr5OSAmcX/IIMt6KtMfny6tTG6e1umWW1JCYsrHTL NwiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=yWmihMqfsSf9BAfab3RhAePc4yFFVM+q8/40vWOWekE=; b=l5lb6ZQ5TFy3Z/3OSYoNLHn864dU9xZXX9OXcWA5kBfZaJxGzHN8kwhweZB096nMcb Ek+5tIlit4quSpByVkUqh7gHDd8UvwwNrFCUyaNANsEPs0XoC5O+Ye52sEzF6p8hB/W5 54smCRZoSrjhwQR2CG63TuO/ml6ANjKRpSfcM1Mk+6xYfrf0gyxU1IBqL4LxhFFTHwFs 2ZxNzF8YnD00M237ERJwAHc/KMhW+oO31NhT0aTIyucLUs/w06AKw2KBxuq8pY4uHMnB LySjzUe/Cdx9PTpFrcOq9MLkkZX4cWUFfS9hAT4GP0op2B1yRq78Dgt5pmlWY0bsQYJD 3TLg== X-Gm-Message-State: ALKqPwdsp0eDrgr9Z+g9mTmyQgaGfEFMDE/86u1nPup1ckRqE8DCgLQm c70jRj6oRVm7Q4LEAjt7ulY= X-Google-Smtp-Source: ADUXVKI/I+44I/2EyKzF10OBP7ZsVM9JYr3LMyODrVfKrdAbhIHoLd6Hq2N2+FuhPsMzyoZRZRJDpQ== X-Received: by 2002:a62:418b:: with SMTP id g11-v6mr17809511pfd.51.1528034961624; Sun, 03 Jun 2018 07:09:21 -0700 (PDT) Received: from calancha-pc (228.225.128.101.dy.bbexcite.jp. [101.128.225.228]) by smtp.gmail.com with ESMTPSA id k24-v6sm84353022pfi.37.2018.06.03.07.09.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 Jun 2018 07:09:21 -0700 (PDT) From: Tino Calancha X-Google-Original-From: Tino Calancha Date: Sun, 3 Jun 2018 23:09:18 +0900 (JST) X-X-Sender: calancha@calancha-pc In-Reply-To: <87sh647ysx.fsf@gmail.com> Message-ID: References: <874lik57ub.fsf@gmail.com> <87vab07zu2.fsf@gmail.com> <87y3fw3rmh.fsf@gmail.com> <87sh647ysx.fsf@gmail.com> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset=US-ASCII X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On Sun, 3 Jun 2018, Noam Postavsky wrote: > Tino Calancha writes: > >> +(defmacro dotimes-with-progress-reporter (spec reporter-or-message &rest body) > >> + (let ((prep (make-symbol "--dotimes-prep--")) >> + ((end (make-symbol "--dotimes-end--")))) >> + `(let ((,prep ,reporter-or-message) >> + (,end ,(cadr spec))) >> + (when (stringp ,prep) >> + (setq ,prep (make-progress-reporter ,prep 0 ,end))) >> + (dotimes ,spec > > That's still going to evaluate (cadr spec) twice. You need to change > the spec passed to `dotimes' so that it also uses `end'. Ah! I am stupid, I did it in Bug#31697 but forgot here :-| Thank you very much for let me know! I hope it's OK know (I cross my fingers). --8<-----------------------------cut here---------------start------------->8--- commit 7c088017a8c0c5446d0c09202aec6d60416b0843 Author: Tino Calancha Date: Sun Jun 3 23:07:20 2018 +0900 dotimes-with-progress-reporter: Polymorphic 2nd argument * lisp/subr.el (dotimes-with-progress-reporter): Allow 2nd arg to be a string or a progress reporter (Bug#31696). * doc/lispref/display.texi (node Progress): Update manual. diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi index ce7ec3ac10..8591fa8cef 100644 --- a/doc/lispref/display.texi +++ b/doc/lispref/display.texi @@ -469,7 +469,7 @@ Progress Secondly, @samp{done} is more explicit. @end defun -@defmac dotimes-with-progress-reporter (var count [result]) message body@dots{} +@defmac dotimes-with-progress-reporter (var count [result]) reporter-or-message body@dots{} This is a convenience macro that works the same way as @code{dotimes} does, but also reports loop progress using the functions described above. It allows you to save some typing. @@ -483,6 +483,18 @@ Progress "Collecting some mana for Emacs..." (sit-for 0.01)) @end example + + +The second argument @code{reporter-or-message} might be a progress +reporter object. This is useful if you want to specify the optional +arguments in @code{make-progress-reporter}. +For instance, you can write previous example as follows: +@example +(dotimes-with-progress-reporter + (k 500) + (make-progress-reporter "Collecting some mana for Emacs..." 0 500 0 1 1.5) + (sit-for 0.01)) +@end example @end defmac @node Logging Messages diff --git a/lisp/subr.el b/lisp/subr.el index 914112ccef..03e64e04c7 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -5013,32 +5013,34 @@ progress-reporter-done "Print reporter's message followed by word \"done\" in echo area." (message "%sdone" (aref (cdr reporter) 3))) -(defmacro dotimes-with-progress-reporter (spec message &rest body) +(defmacro dotimes-with-progress-reporter (spec reporter-or-message &rest body) "Loop a certain number of times and report progress in the echo area. Evaluate BODY with VAR bound to successive integers running from 0, inclusive, to COUNT, exclusive. Then evaluate RESULT to get the return value (nil if RESULT is omitted). -At each iteration MESSAGE followed by progress percentage is -printed in the echo area. After the loop is finished, MESSAGE -followed by word \"done\" is printed. This macro is a -convenience wrapper around `make-progress-reporter' and friends. +REPORTER-OR-MESSAGE is a progress reporter object or a string. In the latter +case, use this string to create a progress reporter. + +At each iteration, print the reporter message followed by progress +percentage in the echo area. After the loop is finished, +print the reporter message followed by word \"done\". + +This macro is a convenience wrapper around `make-progress-reporter' and friends. \(fn (VAR COUNT [RESULT]) MESSAGE BODY...)" (declare (indent 2) (debug ((symbolp form &optional form) form body))) - (let ((temp (make-symbol "--dotimes-temp--")) - (temp2 (make-symbol "--dotimes-temp2--")) - (start 0) - (end (nth 1 spec))) - `(let ((,temp ,end) - (,(car spec) ,start) - (,temp2 (make-progress-reporter ,message ,start ,end))) - (while (< ,(car spec) ,temp) - ,@body - (progress-reporter-update ,temp2 - (setq ,(car spec) (1+ ,(car spec))))) - (progress-reporter-done ,temp2) - nil ,@(cdr (cdr spec))))) + (let ((prep (make-symbol "--dotimes-prep--")) + ((end (make-symbol "--dotimes-end--")))) + `(let ((,prep ,reporter-or-message) + (,end ,(cadr spec))) + (when (stringp ,prep) + (setq ,prep (make-progress-reporter ,prep 0 ,end))) + (dotimes (,(car spec) ,end) + ,@body + (progress-reporter-update ,prep (1+ ,(car spec)))) + (progress-reporter-done ,prep) + (or ,@(cdr (cdr spec)) nil)))) ;;;; Comparing version strings. --8<-----------------------------cut here---------------end--------------->8--- R From unknown Wed Aug 20 06:39:20 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Tino Calancha Subject: bug#31696: closed (Re: bug#31696: 27.0.50; dotimes-with-progress-reporter: Polimorphic 2nd argument) Message-ID: References: <874li1bvpj.fsf@calancha-pc.dy.bbexcite.jp> <874lik57ub.fsf@gmail.com> X-Gnu-PR-Message: they-closed 31696 X-Gnu-PR-Package: emacs Reply-To: 31696@debbugs.gnu.org Date: Sun, 17 Jun 2018 09:38:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1529228282-31066-1" This is a multi-part message in MIME format... ------------=_1529228282-31066-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #31696: 27.0.50; dotimes-with-progress-reporter: Polimorphic 2nd argument which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 31696@debbugs.gnu.org. --=20 31696: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D31696 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1529228282-31066-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 31696-done) by debbugs.gnu.org; 17 Jun 2018 09:37:14 +0000 Received: from localhost ([127.0.0.1]:52566 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fUU7V-00083x-Pw for submit@debbugs.gnu.org; Sun, 17 Jun 2018 05:37:14 -0400 Received: from mail-pf0-f174.google.com ([209.85.192.174]:34641) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fUU7S-00083i-1D for 31696-done@debbugs.gnu.org; Sun, 17 Jun 2018 05:37:10 -0400 Received: by mail-pf0-f174.google.com with SMTP id a63-v6so6793155pfl.1 for <31696-done@debbugs.gnu.org>; Sun, 17 Jun 2018 02:37:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:references:date:in-reply-to:message-id:user-agent :mime-version; bh=FlXqF1dSVnQvgyuI1l9drceBVHW16MaFrkFbz0KwQ9Q=; b=buQiIiJzIJSKSlsfD8aDh0T2EohNTDsa9fV1NVLRTETN3u5u8ayTqoc7KrxEIGTR/n Q58z8feCPtSkOWdJz/lUhHdBLx9elNIkVBPXiq8zRa42XxVz70fnfODRih0bZXwtA7fM OJb8FD0qAvQ7upjQ+FbnwL1Tj2RZOPcnf1EIJz277XDr6pOhqe8R9ZedXeriTOh1nzC/ EIv3xw7VdH9fmHrO/wfBLd4XqTC+1bZDCXjMIbfolHVI8ORmwoJEnUp/es0nHgeXmtIQ VE9DCXkj0DX0cipR5A3guXb0r3NDAOwoW+kVN9wvsttzqiWuSbk28biOWOOOyzAZmvMd ySAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=FlXqF1dSVnQvgyuI1l9drceBVHW16MaFrkFbz0KwQ9Q=; b=a4zxL9x2A6h9q0xbtRfEtWVPU8fqroD58Qs2ltXWKAsH/pKbkPK3CvH8bRusK3QvCG X0CP9ygd6ZlX1sZLHDcYfZnS6JQ62UswSxn+kzBPAFxOnuF4k3kAKFdo0xNhfkZH4pvg UHJ3rO2PeSKZPsjfpvwYo5/AtmJeuEvzfIqnpSEA0XvUWQKiWyekpTpBLZvgmsq9zsir 21aOLlLYp2FdW0wAbHZWmiq42tELhFWh87v45Hw4mpf4iC4P8pJH0Xb6i3LLrNHxRxB9 0e4ofMcJRKzLijMduj3IzK2N+ZrK6AKBJaJxMR5RSwjtXM5agEpk/AuXtyuCljgtNgHS 3Gqw== X-Gm-Message-State: APt69E1bqof4kfwhJWYuTQNdVQkDQq4aTaDfB1NEhZIDALinU8hIxUZt ObaIcYNldcF62wvVHb+a5vmL3A== X-Google-Smtp-Source: ADUXVKJcqxaxYsg40pDSLwEw/lt+p+9WNSKTbagKM5VYAflVtd4wQ3voyslJGDhZjo3O56jPowNU6Q== X-Received: by 2002:a65:6210:: with SMTP id d16-v6mr7236920pgv.272.1529228223929; Sun, 17 Jun 2018 02:37:03 -0700 (PDT) Received: from calancha-pc.dy.bbexcite.jp ([240f:6e:ee9a:1:adc4:139f:709c:10b]) by smtp.gmail.com with ESMTPSA id t3-v6sm15929353pgs.91.2018.06.17.02.37.01 for <31696-done@debbugs.gnu.org> (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 17 Jun 2018 02:37:03 -0700 (PDT) From: Tino Calancha To: 31696-done@debbugs.gnu.org Subject: Re: bug#31696: 27.0.50; dotimes-with-progress-reporter: Polimorphic 2nd argument References: <874lik57ub.fsf@gmail.com> <87vab07zu2.fsf@gmail.com> <87y3fw3rmh.fsf@gmail.com> <87sh647ysx.fsf@gmail.com> Date: Sun, 17 Jun 2018 18:36:56 +0900 In-Reply-To: (Tino Calancha's message of "Sun, 3 Jun 2018 23:09:18 +0900 (JST)") Message-ID: <874li1bvpj.fsf@calancha-pc.dy.bbexcite.jp> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 31696-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Tino Calancha writes: > On Sun, 3 Jun 2018, Noam Postavsky wrote: > >> Tino Calancha writes: >> >>> +(defmacro dotimes-with-progress-reporter (spec reporter-or-message &rest body) >> >>> + (let ((prep (make-symbol "--dotimes-prep--")) >>> + ((end (make-symbol "--dotimes-end--")))) >>> + `(let ((,prep ,reporter-or-message) >>> + (,end ,(cadr spec))) >>> + (when (stringp ,prep) >>> + (setq ,prep (make-progress-reporter ,prep 0 ,end))) >>> + (dotimes ,spec >> >> That's still going to evaluate (cadr spec) twice. You need to change >> the spec passed to `dotimes' so that it also uses `end'. > I did it in Bug#31697 but forgot here :-| > Thank you very much for let me know! Implemented in master branch as commit 'dotimes-with-progress-reporter: Polymorphic 2nd argument' (5099b3abb2b623ce949b8efc37bee8c41d5ad754) ------------=_1529228282-31066-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 3 Jun 2018 13:16:21 +0000 Received: from localhost ([127.0.0.1]:59876 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fPSrt-0005K2-1h for submit@debbugs.gnu.org; Sun, 03 Jun 2018 09:16:21 -0400 Received: from eggs.gnu.org ([208.118.235.92]:49780) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fPSrr-0005Jm-9A for submit@debbugs.gnu.org; Sun, 03 Jun 2018 09:16:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fPSrk-0003Ep-Qj for submit@debbugs.gnu.org; Sun, 03 Jun 2018 09:16:13 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM, T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:36600) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fPSrk-0003El-My for submit@debbugs.gnu.org; Sun, 03 Jun 2018 09:16:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40735) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fPSrh-0000bf-Sd for bug-gnu-emacs@gnu.org; Sun, 03 Jun 2018 09:16:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fPSrd-0003Df-TR for bug-gnu-emacs@gnu.org; Sun, 03 Jun 2018 09:16:09 -0400 Received: from mail-pg0-x22d.google.com ([2607:f8b0:400e:c05::22d]:36976) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fPSrd-0003DO-Lg for bug-gnu-emacs@gnu.org; Sun, 03 Jun 2018 09:16:05 -0400 Received: by mail-pg0-x22d.google.com with SMTP id a13-v6so13239660pgu.4 for ; Sun, 03 Jun 2018 06:16:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version; bh=+8IIT13MmBaO7qqSc9CE9Xk097uTI2Ah97WGjDaSlR8=; b=AVeaSrGNj1/vim47XzxmJYcrqGGePzETMkS0hOkc4Edf1I/8z3r6oGuI+qZUAxs8Bh pMoHMIZsYOAtb/zUhX+Z6gaS/oiHwmFdHLul7htWyhRIIcoYH8Xc75m5CVUk2I8pA2ru B0TxlxamXd1HHGhNdlyJODl4Te42p+rUX14AVoCTenwQVCOKECKlan1z4WspmqiBjq9E qrAfvnP3Sdi9zl06C21Q0d/pKZYlRU2iL08o+UnDTntf/htJYhxp+/JZwV9hChMKHwVz c+bjUyv44j/edP5UmwHr+LPRwYqNcs19Vj4ZnZ4p7qVENCDaEKb5GqEcq5Kzx4D1pgQD KkKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version; bh=+8IIT13MmBaO7qqSc9CE9Xk097uTI2Ah97WGjDaSlR8=; b=etE6t0C5zgY2oixus++9JwtEjT3dgszLOqeFXwj467R1lYV6XgtPT7Z3C0pRDc+DLD da4IBT7I2V+j8ghqEX86AfhgCm62iA7c1w2OHyhohSZy8TLsafLiJdr8fyNG6D07Qsxa QnwezBn2NYpMLIOEdhwISI2MVzvY78BXF5oA9/mnajHFxpNlPpjjcTYWMHEOUukP40yq E+pgbWX7fCHdQsR52fo4XQW4kvVvYrlOyZpwVlYkRfG8CCpyaih0fF+BZRukU8P1uhoP VS6/suxJF9EmRECZREtm43nzT7wN4AQ+NrwHxXiqsxlqPkI/j68lAb8tAuT1yGHdOT1y R7Yg== X-Gm-Message-State: ALKqPwdCFBguFOX38Sr1W0h3eVg4n8AHt1CZGxrvzkX2iYeaSRTavQ+y hggxtOj+5AkerIBSl5nIjr4T7g== X-Google-Smtp-Source: ADUXVKIqI2ABYlTAcGqSeHEUQ0i6iva8OjDoa+S6CnLxBKgE5d/pbMSid+uisVAZadgp1qparlIZxw== X-Received: by 2002:a62:ea1a:: with SMTP id t26-v6mr17756803pfh.117.1528031764274; Sun, 03 Jun 2018 06:16:04 -0700 (PDT) Received: from calancha-pc (228.225.128.101.dy.bbexcite.jp. [101.128.225.228]) by smtp.gmail.com with ESMTPSA id z129-v6sm70711534pfb.108.2018.06.03.06.16.02 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 03 Jun 2018 06:16:03 -0700 (PDT) From: Tino Calancha To: bug-gnu-emacs@gnu.org Subject: 27.0.50; dotimes-with-progress-reporter: Polimorphic 2nd argument Date: Sun, 03 Jun 2018 22:15:56 +0900 Message-ID: <874lik57ub.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) Severity: Wishlist X-Debbugs-Cc: Stefan Monnier The second arg might be a string or a progress reporter object; the latter is useful if the programmer wish to specify the optional parameters of the reporter. --8<-----------------------------cut here---------------start------------->8--- commit d4d07b0d9a444cc925d0c1c6fbcc155f9709fbe9 Author: Tino Calancha Date: Sun Jun 3 22:06:01 2018 +0900 dotimes-with-progress-reporter: Polimorphic 2nd argument * lisp/subr.el (dotimes-with-progress-reporter): Allow 2nd arg to be a string or a progress reporter (Bug#31696). * doc/lispref/display.texi (node Progress): Update manual. diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi index ce7ec3ac10..8591fa8cef 100644 --- a/doc/lispref/display.texi +++ b/doc/lispref/display.texi @@ -469,7 +469,7 @@ Progress Secondly, @samp{done} is more explicit. @end defun -@defmac dotimes-with-progress-reporter (var count [result]) message body@dots{} +@defmac dotimes-with-progress-reporter (var count [result]) reporter-or-message body@dots{} This is a convenience macro that works the same way as @code{dotimes} does, but also reports loop progress using the functions described above. It allows you to save some typing. @@ -483,6 +483,18 @@ Progress "Collecting some mana for Emacs..." (sit-for 0.01)) @end example + + +The second argument @code{reporter-or-message} might be a progress +reporter object. This is useful if you want to specify the optional +arguments in @code{make-progress-reporter}. +For instance, you can write previous example as follows: +@example +(dotimes-with-progress-reporter + (k 500) + (make-progress-reporter "Collecting some mana for Emacs..." 0 500 0 1 1.5) + (sit-for 0.01)) +@end example @end defmac @node Logging Messages diff --git a/lisp/subr.el b/lisp/subr.el index 914112ccef..a1b2556239 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -5013,32 +5013,32 @@ progress-reporter-done "Print reporter's message followed by word \"done\" in echo area." (message "%sdone" (aref (cdr reporter) 3))) -(defmacro dotimes-with-progress-reporter (spec message &rest body) +(defmacro dotimes-with-progress-reporter (spec reporter-or-message &rest body) "Loop a certain number of times and report progress in the echo area. Evaluate BODY with VAR bound to successive integers running from 0, inclusive, to COUNT, exclusive. Then evaluate RESULT to get the return value (nil if RESULT is omitted). -At each iteration MESSAGE followed by progress percentage is -printed in the echo area. After the loop is finished, MESSAGE -followed by word \"done\" is printed. This macro is a -convenience wrapper around `make-progress-reporter' and friends. +REPORTER-OR-MESSAGE is a progress reporter object or a string. In the latter +case, use this string to create a progress reporter. + +At each iteration, print the reporter message followed by progress +percentage in the echo area. After the loop is finished, +print the reporter message followed by word \"done\". + +This macro is a convenience wrapper around `make-progress-reporter' and friends. \(fn (VAR COUNT [RESULT]) MESSAGE BODY...)" (declare (indent 2) (debug ((symbolp form &optional form) form body))) - (let ((temp (make-symbol "--dotimes-temp--")) - (temp2 (make-symbol "--dotimes-temp2--")) - (start 0) - (end (nth 1 spec))) - `(let ((,temp ,end) - (,(car spec) ,start) - (,temp2 (make-progress-reporter ,message ,start ,end))) - (while (< ,(car spec) ,temp) - ,@body - (progress-reporter-update ,temp2 - (setq ,(car spec) (1+ ,(car spec))))) - (progress-reporter-done ,temp2) - nil ,@(cdr (cdr spec))))) + (let ((prep (make-symbol "--dotimes-prep--"))) + `(let ((,prep ,reporter-or-message)) + (when (stringp ,prep) + (setq ,prep (make-progress-reporter ,prep 0 ,(cadr spec)))) + (dotimes ,spec + ,@body + (progress-reporter-update ,prep (1+ ,(car spec)))) + (progress-reporter-done ,prep) + (or ,@(cdr (cdr spec)) nil)))) ;;;; Comparing version strings. --8<-----------------------------cut here---------------end--------------->8--- In GNU Emacs 27.0.50 (build 78, x86_64-pc-linux-gnu, GTK+ Version 3.22.11) of 2018-06-03 built on calancha-pc Repository revision: e75c57f10ee9418599398361b0676f48d265fb12 ------------=_1529228282-31066-1--