From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jari Aalto Newsgroups: gmane.emacs.bugs Subject: bug#7679: wishlist: add new library map-progress.el - mapping macros that report progress (Jonas Bernoulli) Date: Sun, 19 Dec 2010 14:37:05 +0200 Message-ID: <871v5eym4u.fsf@picasso.cante.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1292763224 27144 80.91.229.12 (19 Dec 2010 12:53:44 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 19 Dec 2010 12:53:44 +0000 (UTC) Cc: jonas bernoulli To: 7679@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Dec 19 13:53:40 2010 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PUIlf-0004SI-QH for geb-bug-gnu-emacs@m.gmane.org; Sun, 19 Dec 2010 13:53:40 +0100 Original-Received: from localhost ([127.0.0.1]:42235 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PUIlf-0007ZO-75 for geb-bug-gnu-emacs@m.gmane.org; Sun, 19 Dec 2010 07:53:39 -0500 Original-Received: from [140.186.70.92] (port=56896 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PUIkt-0007At-VG for bug-gnu-emacs@gnu.org; Sun, 19 Dec 2010 07:52:53 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PUIks-0003Wx-6M for bug-gnu-emacs@gnu.org; Sun, 19 Dec 2010 07:52:51 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:56276) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PUIkr-0003Wq-Vj for bug-gnu-emacs@gnu.org; Sun, 19 Dec 2010 07:52:50 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1PUIPl-0002Hk-V5; Sun, 19 Dec 2010 07:31:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Jari Aalto Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: jonas@bernoul.li, bug-gnu-emacs@gnu.org Resent-Date: Sun, 19 Dec 2010 12:31:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 7679 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: submit@debbugs.gnu.org X-Debbugs-Original-Xcc: jonas bernoulli Original-Received: via spool by submit@debbugs.gnu.org id=B.12927618468760 (code B ref -1); Sun, 19 Dec 2010 12:31:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 19 Dec 2010 12:30:46 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PUIPW-0002HE-6u for submit@debbugs.gnu.org; Sun, 19 Dec 2010 07:30:46 -0500 Original-Received: from emh07.mail.saunalahti.fi ([62.142.5.117]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PUIPS-0002H0-Tk for submit@debbugs.gnu.org; Sun, 19 Dec 2010 07:30:44 -0500 Original-Received: from saunalahti-vams (vs3-11.mail.saunalahti.fi [62.142.5.95]) by emh07-2.mail.saunalahti.fi (Postfix) with SMTP id 4C8E718CE09 for ; Sun, 19 Dec 2010 14:37:08 +0200 (EET) Original-Received: from emh02.mail.saunalahti.fi ([62.142.5.108]) by vs3-11.mail.saunalahti.fi ([62.142.5.95]) with SMTP (gateway) id A01DD6486BB; Sun, 19 Dec 2010 14:37:08 +0200 Original-Received: from picasso.cante.net (a91-155-187-216.elisa-laajakaista.fi [91.155.187.216]) by emh02.mail.saunalahti.fi (Postfix) with ESMTP id 020452BD43 for ; Sun, 19 Dec 2010 14:37:06 +0200 (EET) Mail-Copies-To: poster X-Antivirus: VAMS X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Sun, 19 Dec 2010 07:31:01 -0500 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:42636 Archived-At: --=-=-= Content-Type: text/plain Package: emacs Version: 23.2+1-5.1 Severity: wishlist X-debbugs-cc: Jonas Bernoulli I would be nice if the progress indicator library map-progress.el by Jonas Bernoulli. were included in Emacs The code repository is at: https://github.com/emacsmirror/map-progress/blob/master/map-progress.el Attached also below as of 2010-12-19 14:35 UTC: 1f15042 2010-08-21 map-with-progress-reporter: fix names of internal variables -- System Information Debian Release: squeeze/sid APT Prefers testing APT policy: (990, testing) (500, unstable) (1, experimental) Architecture: amd64 Kernel: Linux picasso 2.6.32-5-amd64 #1 SMP Fri Sep 17 21:50:19 UTC 2010 x86_64 GNU/Linux Locale: LANG=en_DK.UTF-8 -- Versions of packages `emacs depends on'. Depends: emacs23 23.2+1-5.1 GNU Emacs is the extensible self-documenting emacs23-lucid 23.2+1-5.1 GNU Emacs is the extensible self-documenting emacs23-nox 23.2+1-5.1 GNU Emacs is the extensible self-documenting --=-=-= Content-Type: text/x-emacs-lisp Content-Disposition: inline; filename=map-progress.el ;;; map-progress.el --- mapping macros that report progress ;; Copyright (C) 2010 Jonas Bernoulli ;; Author: Jonas Bernoulli ;; Created: 20100714 ;; Updated: 20100810 ;; Version: 0.2 ;; Homepage: https://github.com/tarsius/map-progress/ ;; Keywords: convenience ;; This file is not part of GNU Emacs. ;; This file is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 3, or (at your option) ;; any later version. ;; This file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see . ;;; Commentary: ;; This library defines mapping macros that report progress. ;; For many of the standard and CL mapping functions like `mapc' macros ;; like `mapc-with-progress-reporter' are defined here. The arguments ;; have the same meaning as the respective arguments of the respective ;; function and `make-progress-reporter', which ever has an argument by ;; the same name. ;; Even when the respective function supports multiple sequences the ;; macros defined here only support one. One the other hand all of the ;; `make-progress-reporter' arguments except for MESSAGE are optional. ;; This includes the starting and final state argument. ;; Any mapping function with only exactly two mandatory arguments - a ;; function which is applied to a sequence - are supported by ;; `map-with-progress-reporter' which can be used when no specialized ;; macro corresponding to a particular function exists, but additional ;; arguments are not supported. ;; Therefor at least the following functions are not supported: `map'. ;; However support for the following divergent mapping functions has ;; been implemented: . ;;; Code: (eval-when-compile (require 'cl)) (defmacro map-with-progress-reporter (msg map fn seq &optional min max &rest rest) "Apply FUNCTION to each element of SEQUENCE using mapping function MAP. Report progress in the echo. Also see `make-progress-reporter'. \(fn MESSAGE MAP FUNCTION SEQUENCE [MIN-VALUE MAX-VALUE CURRENT-VALUE MIN-CHANGE MIN-TIME])" (let ((idx (make-symbol "--map-with-progress-idx--")) (msm (make-symbol "--map-with-progress-msm--")) (lst (make-symbol "--map-with-progress-lst--")) (prg (make-symbol "--map-with-progress-prg--")) (elt (make-symbol "--map-with-progress-elt--"))) `(let* ((,idx 0) (,msm ,msg) (,lst ,seq) (,prg (make-progress-reporter ,msm (or ,min 0) (or ,max (length ,lst)) ,@rest))) (prog1 (funcall ,map (lambda (,elt) (prog1 (funcall ,fn ,elt) (progress-reporter-update ,prg (incf ,idx)))) ,lst) (progress-reporter-done ,prg))))) (defmacro mapc-with-progress-reporter (msg fn seq &optional min max &rest rest) "Like `mapc' but report progress in the echo area. Also see `make-progress-reporter'. \(fn MESSAGE FUNCTION SEQUENCE [MIN-VALUE MAX-VALUE CURRENT-VALUE MIN-CHANGE MIN-TIME])" `(map-with-progress-reporter ,msg 'mapc ,fn ,seq ,min ,max ,@rest)) (defmacro mapcan-with-progress-reporter (msg fn seq &optional min max &rest rest) "Like `mapcan' but report progress in the echo area. There may be only one SEQUENCE. Also see `make-progress-reporter'. \(fn MESSAGE FUNCTION SEQUENCE [MIN-VALUE MAX-VALUE CURRENT-VALUE MIN-CHANGE MIN-TIME])" `(map-with-progress-reporter ,msg 'mapcan ,fn ,seq ,min ,max ,@rest)) (defmacro mapcar-with-progress-reporter (msg fn seq &optional min max &rest rest) "Like `mapcar' but report progress in the echo area. Also see `make-progress-reporter'. \(fn MESSAGE FUNCTION SEQUENCE [MIN-VALUE MAX-VALUE CURRENT-VALUE MIN-CHANGE MIN-TIME])" `(map-with-progress-reporter ,msg 'mapcar ,fn ,seq ,min ,max ,@rest)) (defmacro mapcon-with-progress-reporter (msg fn seq &optional min max &rest rest) "Like `mapcon' but report progress in the echo area. There may be only one SEQUENCE. Also see `make-progress-reporter'. \(fn MESSAGE FUNCTION SEQUENCE [MIN-VALUE MAX-VALUE CURRENT-VALUE MIN-CHANGE MIN-TIME])" `(map-with-progress-reporter ,msg 'mapcon ,fn ,seq ,min ,max ,@rest)) (defmacro mapl-with-progress-reporter (msg fn seq &optional min max &rest rest) "Like `mapl' but report progress in the echo area. There may be only one SEQUENCE. Also see `make-progress-reporter'. \(fn MESSAGE FUNCTION SEQUENCE [MIN-VALUE MAX-VALUE CURRENT-VALUE MIN-CHANGE MIN-TIME])" `(map-with-progress-reporter ,msg 'mapl ,fn ,seq ,min ,max ,@rest)) (defmacro maplist-with-progress-reporter (msg fn seq &optional min max &rest rest) "Like `maplist' but report progress in the echo area. There may be only one SEQUENCE. Also see `make-progress-reporter'. \(fn MESSAGE FUNCTION SEQUENCE [MIN-VALUE MAX-VALUE CURRENT-VALUE MIN-CHANGE MIN-TIME])" `(map-with-progress-reporter ,msg 'maplist ,fn ,seq ,min ,max ,@rest)) (defmacro mapatoms-with-progress-reporter (msg fn seq &optional min max &rest rest) "Like `mapatoms' but report progress in the echo area. Also see `make-progress-reporter'. \(fn MESSAGE FUNCTION [OBARRAY MIN-VALUE MAX-VALUE CURRENT-VALUE MIN-CHANGE MIN-TIME])" `(map-with-progress-reporter ,msg 'mapatoms ,fn ,seq ,min ,max ,@rest)) (defmacro maphash-with-progress-reporter (msg fn seq &optional min max &rest rest) "Like `maphash' but report progress in the echo area. Also see `make-progress-reporter'. \(fn MESSAGE FUNCTION HASH [MIN-VALUE MAX-VALUE CURRENT-VALUE MIN-CHANGE MIN-TIME])" `(map-with-progress-reporter ,msg 'maphash ,fn ,seq ,min ,max ,@rest)) (defmacro map-keymap-internal-with-progress-reporter (msg fn seq &optional min max &rest rest) "Like `map-keymap-internal' but report progress in the echo area. Also see `make-progress-reporter'. \(fn MESSAGE FUNCTION KEYMAP [MIN-VALUE MAX-VALUE CURRENT-VALUE MIN-CHANGE MIN-TIME])" `(map-with-progress-reporter ,msg 'map-keymap-internal ,fn ,seq ,min ,max ,@rest)) (provide 'map-progress) ;;; map-progress.el ends here --=-=-=--