From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: W. Greenhouse Newsgroups: gmane.emacs.help Subject: Re: Multitasking in emacs? Date: Fri, 20 Jun 2014 07:07:45 +0000 Message-ID: <87zjh8hxdq.fsf@motoko.kusanagi> References: <87zjh8ozuf.fsf@gmx.at> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1403248115 27470 80.91.229.3 (20 Jun 2014 07:08:35 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 20 Jun 2014 07:08:35 +0000 (UTC) To: help-gnu-emacs-mXXj517/zsQ@public.gmane.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org-mXXj517/zsQ@public.gmane.org Fri Jun 20 09:08:30 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Wxsw0-0000sT-T0 for geh-help-gnu-emacs@m.gmane.org; Fri, 20 Jun 2014 09:08:29 +0200 Original-Received: from localhost ([::1]:39305 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wxsvx-0000Ur-7v for geh-help-gnu-emacs@m.gmane.org; Fri, 20 Jun 2014 03:08:25 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58264) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wxsvi-0000Tq-7b for help-gnu-emacs-mXXj517/zsQ@public.gmane.org; Fri, 20 Jun 2014 03:08:14 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wxsvd-0003vB-Fa for help-gnu-emacs-mXXj517/zsQ@public.gmane.org; Fri, 20 Jun 2014 03:08:10 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:49816) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wxsvd-0003v0-91 for help-gnu-emacs-mXXj517/zsQ@public.gmane.org; Fri, 20 Jun 2014 03:08:05 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1WxsvX-0000Nw-Io for help-gnu-emacs-mXXj517/zsQ@public.gmane.org; Fri, 20 Jun 2014 09:07:59 +0200 Original-Received: from tor-exit.server6.tvdw.eu ([5.79.68.161]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 20 Jun 2014 09:07:59 +0200 Original-Received: from wgreenhouse by tor-exit.server6.tvdw.eu with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 20 Jun 2014 09:07:59 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 64 Original-X-Complaints-To: usenet-dbVV3NMTNubNLxjTenLetw@public.gmane.org X-Gmane-NNTP-Posting-Host: tor-exit.server6.tvdw.eu X-Archive: encrypt User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:55dxPM7iTqnuCyY0oXoXLQTDcNc= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: help-gnu-emacs-mXXj517/zsQ@public.gmane.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org-mXXj517/zsQ@public.gmane.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org-mXXj517/zsQ@public.gmane.org Xref: news.gmane.org gmane.emacs.help:98346 Archived-At: Hi Martin, Martin writes: > Hi there, > > When I do a update of the packages, like > > M-X list-packages RET U x y > > or when I send large emails, emacs seems to stop me from working for the > time this processes are running. Is there a way to put this processes > in the background and working on in other buffers? Emacs is usually confined to a single thread of execution and does not [yet] have a general concept of concurrency. Instead it cleverly uses subprocesses and asynchronous I/O to achieve concurrency-like effects in some situations. For talking to external subprocesses and network sockets, Emacs can use `start-process' to make an asynchronous process, and then receive buffered output (over pty or pipe) when it's idle, using "process filters." Elisp programs that use `start-process' can feel almost like they are running in multiple threads, but if Emacs needs to do a lot of processing after receiving the subprocess results, that will block the event loop and the user will have to wait. There is a concurrency (multithreading as opposed to the async I/O concept above) branch of Emacs with approximately one person working on it. There are also some libraries to do async I/O for elisp itself (or specific tasks in elisp), by spawning extra worker emacsen, including: - Elnode -- uses a herd of asynchronous Emacsen to provide an nginx-like event-driven webserver. Currently powering the marmalade-repo.org ELPA repo, among other things. - async.el -- simple, general-purpose async elisp library that uses similar concepts to elnode: a subprocess Emacs is spawned, given an execution environment (just the vars and bindings relevant to the calculation) and told to eval something. NB: you do have to rewrite your elisp to make use of async.el, but one of the proof of concept setups is to allow message-mode to send mail in a background job. - Gnus can do some things asynchronously, by using the Agent functionality and emacs --batch. This batch Gnus process can do things like automatically download messages and send mail from your queue. (info "(gnus) Batching Agents") - org-mode can run the export functionality asynchronously in a subprocess worker Emacs. With the async I/O idea, there's not yet a way to just tell any arbitrary elisp function to automatically run in a "background" subprocess Emacs, because you need to pass it the state relevant to the job it needs to do. Hope that helps give you a better idea of what's happening, even if it doesn't provide an immediate solution. But for the mail issue, perhaps you could try async.el's smtpmail wrapper or gnus-agent-batch. -- Best, WGG