From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: zsh-users-return-23716-ml=inbox.vuxu.org@zsh.org X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 012953d5 for ; Wed, 24 Oct 2018 08:44:23 +0000 (UTC) Received: (qmail 4520 invoked by alias); 24 Oct 2018 08:44:06 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: List-Unsubscribe: X-Seq: 23716 Received: (qmail 16802 invoked by uid 1010); 24 Oct 2018 08:44:06 -0000 X-Qmail-Scanner-Diagnostics: from mail-ot1-f46.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(209.85.210.46):SA:0(-1.9/5.0):. Processed in 4.140275 secs); 24 Oct 2018 08:44:06 -0000 X-Envelope-From: sgniazdowski@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to :content-transfer-encoding; bh=lYddiUZDnakIccRaU3ClnVURQ3hkgRIZM2KCdWziR0Q=; b=nkDhJYdL5jc5E+5rhiYZ+FYDYODH3KjYBU6NefE5PsbxjSUHWsBwCwoq6lWfTcQ8dM 0xpSX98JNiFXTAvvfP7MPocZG4XUhkSwlqC1zETGOZ/9d/wMSaQ8aNFefylRDzA/0B7k y2Z7tQHKcfCiDm4AKrUFSz/IbyjwrMxcIe1KE4AF60bEDhEnqlGl7Aa/arof5Q2bcEZG 32uEBU7zdhA7gf5tkZUhYmpS7GiJOTLabtuI2H00m3+G5XA2nVc3Xx6046T1VkBLJKph xw/DjnzjaJqXNxOnDBDexmOfVqEJVHWqhD5uUrjvJMFEGpjZXPauRCnO53LQix2S8zZ2 SRGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to :content-transfer-encoding; bh=lYddiUZDnakIccRaU3ClnVURQ3hkgRIZM2KCdWziR0Q=; b=kUErXqwZ+3PKjCsrcmOy1pHZ7cSg5ZqNwzSJPFuHZV8EkMm5cyEuJ6Jr3aafhS/jVB KTh4sqhT6bnoh5vnIDBcgWgp+qq5QvFLuYvpHFDQWRIcUFGauWAsHMgM8uBWfLYge80P wx+s+vUl261vWOl2Oc24gG3MS+sHgU4gd7Nmrh5Zym0Zbkv/SWAeUaFGgmN8qQJl+TI6 3+/6lBYz4gp7P8KsxnB1PYIdBiFIXaIGzmO+nKrtaBuPW2+ZOzOOO3mGuuTw8a3Et9E5 0kOBhlqB2gHpm8wr1Mqs9SOs8h7weHhJo4gs2SarxG6hWwxeraCFjpVuf7ZBd49rBiiu jn5A== X-Gm-Message-State: AGRZ1gJr+Y0j0oI0q6VT3bvlB3T+m8RlOa9/BTnJUhpTUeLyQorOUTsy OefQLOmINowF7MqYT8GFHez/M8h4eSkvewTzGmNDOoN0 X-Google-Smtp-Source: AJdET5dlTPzsGc1JNMXFZmJsIoj6uLRo2ys32qmxkiuKFcsAl7JAguepH/WxVbElFbqHs8CuKPWgaGbWohQjw+ssp6w= X-Received: by 2002:a9d:3284:: with SMTP id u4mr1185498otb.134.1540370637953; Wed, 24 Oct 2018 01:43:57 -0700 (PDT) MIME-Version: 1.0 From: Sebastian Gniazdowski Date: Wed, 24 Oct 2018 10:43:45 +0200 Message-ID: Subject: Cool presentation of Asynchronicity, a recent buzz-word in Zsh topic To: Zsh Users Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hello, from some time (1 or 1.5 years?) there's the topic of async-operation in Zsh plugins. There's the plugin mafredri/zsh-async, which uses module zsh/zpty to run background task and return via zle -F handler. I've discovered that <( ) is a good method to run background task. It is simpler than using an API of a plugin and very simple in general. Three lines of code are needed to run a task in background: exec {ZTSFD}< <(LANG=3DC sleep 0.3; print -r -- $CUR_SECONDS) command true # workaround Zsh bug zle -F -w "$ZTSFD" zts_postponed_redisplay After that, after 300 ms, zts_postponed_redisplay() will be called (if the command line is unused, free), with stdin plugged so that it can read $CUR_SECONDS. There's Zsh bug, and a risk of segfaults, I wasn't able to track this fully (only found the workaround), but I've made a plugin that makes intense use of <( ), and here's the result (the presentation of async-work) =E2=80=93 smooth operation without problems: https://asciinema.org/a/207856 --=20 Sebastian Gniazdowski News: https://twitter.com/ZdharmaI IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin Blog: http://zdharma.org