From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.bugs Subject: bug#23430: 25.0.93; iter-defun does not support special form save-current-buffer Date: Sun, 16 Aug 2020 15:33:38 +0200 Message-ID: <87tux2btql.fsf@web.de> References: <86k2jc2ahf.fsf@yandex.ru> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26595"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 23430@debbugs.gnu.org, Stefan Kangas To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Aug 16 15:34:42 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k7Io6-0006nR-8o for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 16 Aug 2020 15:34:42 +0200 Original-Received: from localhost ([::1]:54248 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k7Io4-0003ZO-9u for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 16 Aug 2020 09:34:40 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38528) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k7InS-0003ZH-SI for bug-gnu-emacs@gnu.org; Sun, 16 Aug 2020 09:34:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:45508) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k7InS-0006fo-HN for bug-gnu-emacs@gnu.org; Sun, 16 Aug 2020 09:34:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1k7InS-0004Y6-E5 for bug-gnu-emacs@gnu.org; Sun, 16 Aug 2020 09:34:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Michael Heerdegen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 16 Aug 2020 13:34:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23430 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: moreinfo Original-Received: via spool by 23430-submit@debbugs.gnu.org id=B23430.159758483017465 (code B ref 23430); Sun, 16 Aug 2020 13:34:02 +0000 Original-Received: (at 23430) by debbugs.gnu.org; 16 Aug 2020 13:33:50 +0000 Original-Received: from localhost ([127.0.0.1]:57054 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k7InF-0004Xc-T0 for submit@debbugs.gnu.org; Sun, 16 Aug 2020 09:33:50 -0400 Original-Received: from mout.web.de ([212.227.15.14]:35117) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k7InC-0004XN-ER for 23430@debbugs.gnu.org; Sun, 16 Aug 2020 09:33:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1597584820; bh=SS2eIwBJivBbz5dAd6NoFBmGpHdWEYHxRh/grnp3L+0=; h=X-UI-Sender-Class:From:To:Cc:Subject:References:Date:In-Reply-To; b=gxwk74IUwCZKRnLfe8NI6aB/2qb/8BfpJYj/72WqftfkIs0zvaijqy0DfLc26sls0 utzOV3AzuEc8YSXIM+zYRMwPWSl2HOPg8YtDcX4gbTsnAxi8cKtJWuweYZtO/QJYvf U4Fxe/vHY05RWf0wGkYRbKrv2mLBbvI7eH8qmWHg= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Original-Received: from drachen.dragon ([217.247.71.68]) by smtp.web.de (mrweb004 [213.165.67.108]) with ESMTPSA (Nemesis) id 0MVGow-1kBAwn3naQ-00YgVA; Sun, 16 Aug 2020 15:33:39 +0200 In-Reply-To: (Dmitry Gutov's message of "Wed, 12 Aug 2020 13:06:33 +0300") X-Provags-ID: V03:K1:SwNY/zkzj/TVma/uzrGycAaX0GtxaShaJATunRluXP1hUmxWdwo /lhToE9vKFNpWLjdcpN7pwrEPsQDYbgbp8JF4keEzOArySHDPhlQFX/5EaXurGbl5VurjJR OivHnsa+dkkSxlVX7iQEaiAG8BhyZmlRzZQTEt36tK1Dc1l4biYGBXIWdCH0qHYOAHxBvKn 4BAD7jnd8Ih0TR+kV1BJQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:t01n49wZAUA=:s8iTQaVHYxRli5juRziuHH jw5lb3wJOmoGnmv59nAnrHEii5WUkP1jWCM8oFmlSWz7j5bGqcxPfyZUPAjth5uBAzM53ODMi WIyLugCskLqTUULdGW4tFkPMm5z7JlRAa87HNYoXOKJp0v9Q+Ap4fzJQH+CPPKDZhj2mFjMcV Z/ySgWMYvokf4rUP7KcRW1MKzkvUjtDppwU/eqoTiQaKiVCVjcvbE54AdDMLP7/RF6/L6odhC LJXhYKj3Vaiduec3rpso9C/lRJ7FalmOm4fAXG1+FE/kfrqiGJA1G44HzHDk8uCPs4NXOerzG L4ZLhUjpP/olaphRBypIT31N+VqTtUpmHJHVNiey5SUk9yaJwAoOSBOwyhZZZWl5NdjCqFAsR vo97pKms/ueolcp2GvyAbFQQ9vaCPakOkEkv0mBrMR+81EjKQ7Un6ZBelXFlzHcsDYbl06S4G eoA2u1JSwfBUhBwYiMsx4NTBcj4k7Ce1/kBAARitohCRRpOOuVntahTOZ+9VccRz0wxwl7iXk b/3KB9Spob/QVCq9tbpto+JJ54radECtS/lTNMpjckA+9Z6IYc+o/lLnu0eqgAWLv2fyVD8BP gdr1uzFR4owHgEfB/9wPgykTUr7G8mRdXz/9XBjWc2X/hFaMBb8tQILWjHkyfD6C4DKXUyQy5 UPO3fQEorPUK/GTZTgNUKxQP+YhSM02eywv9YaHw3bmCbVU0yW3IKiuyQv0hzYvXEQ+W1uU3Y VxGOJaUPbdGminWqXalS4PvV2JOSa24aMxX/weDlu9WRs7CbFhdDZpeD2TidH0p4QqivC8mV X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:185278 Archived-At: Dmitry Gutov writes: > Before we close this, I'd like to hear from somebody who understands > what generator.el is actually for. I think it's just a straightforward implementation of generators as described here: https://en.wikipedia.org/wiki/Generator_%28computer_programming%29 I learned about them in university, and have used them once in a while. AFAIK handling asynchronous process output is not a good task for them. I think: The problem of the concept of generators in an editor is that generators are good for saving the state of a computation, but Emacs as an editor has a lot of "environment" state (current buffer, value of point, ...), and when the computation represented by the generator messes with this state (or has side effects), the concept doesn't fit that well. When working with streams, I make the handling of the according part of the environment explicit saving it in variables (iterators are closures) and "yield" outside of any xxx-recursion, in your introductory example, that would look like this: #+begin_src emacs-lisp (require 'generator) (iter-defun my-search (str buf) (with-current-buffer buf (goto-char (point-min))) (let ((pos (point)) (yield nil) (done nil)) (while (not done) (when yield (iter-yield yield) (setq yield nil)) (with-current-buffer buf (goto-char pos) (if (search-forward str) (setq yield (match-beginning 0) pos (point)) (setq done 0)))))) #+end_src I guess it would be nice if that could work implicitly in some way, but that would probably require the introduction of new special forms adapted to the situation, like `iterator-save-buffer-and-point' or so. Just extrapolating my university knowledge however... Michael.