From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: & and M-& to run programs asynchronously Date: Tue, 30 Jun 2009 03:02:45 +0300 Organization: JURTA Message-ID: <87hbxy373a.fsf@mail.jurta.org> References: <87hcbkpo0e.fsf@gmail.com> <86y74wzeq1.fsf@lola.quinscape.zz> <874p7ifonh.fsf@jurta.org> <873amryzdu.fsf_-_@gmail.com> <87iqt9dwtm.fsf@gmail.com> <87zlmfpov5.fsf@jurta.org> <87tz20660j.fsf@yahoo.com> <873a9km3fh.fsf@mail.jurta.org> <87y6rbgez1.fsf@CPU107.opentrends.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1246321630 25229 80.91.229.12 (30 Jun 2009 00:27:10 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 30 Jun 2009 00:27:10 +0000 (UTC) Cc: emacs-devel@gnu.org To: Daniel Clemente Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Jun 30 02:27:03 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MLRBZ-0005jq-86 for ged-emacs-devel@m.gmane.org; Tue, 30 Jun 2009 02:27:02 +0200 Original-Received: from localhost ([127.0.0.1]:44838 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MLRBU-0007z8-4a for ged-emacs-devel@m.gmane.org; Mon, 29 Jun 2009 20:26:52 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MLRAY-0007A6-At for emacs-devel@gnu.org; Mon, 29 Jun 2009 20:25:54 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MLRAT-00073L-9c for emacs-devel@gnu.org; Mon, 29 Jun 2009 20:25:53 -0400 Original-Received: from [199.232.76.173] (port=49120 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MLRAT-000738-5x for emacs-devel@gnu.org; Mon, 29 Jun 2009 20:25:49 -0400 Original-Received: from smtp-out3.starman.ee ([85.253.0.5]:55228 helo=smtp-gw1.starman.ee) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MLRAS-0007ws-KP for emacs-devel@gnu.org; Mon, 29 Jun 2009 20:25:49 -0400 Original-Received: from mx2.starman.ee (mx2.starman.ee [62.65.192.17]) by smtp-gw1.starman.ee (Postfix) with ESMTP id 5B33BA21529; Tue, 30 Jun 2009 03:25:45 +0300 (EEST) X-Virus-Scanned: by Amavisd-New at mx2.starman.ee Original-Received: from mail.starman.ee (82.131.55.132.cable.starman.ee [82.131.55.132]) by mx2.starman.ee (Postfix) with ESMTP id 42B743F4054; Tue, 30 Jun 2009 03:25:41 +0300 (EEST) In-Reply-To: <87y6rbgez1.fsf@CPU107.opentrends.net> (Daniel Clemente's message of "Mon, 29 Jun 2009 18:52:02 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (x86_64-pc-linux-gnu) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:111825 Archived-At: >>> Could the patch for M-&=async-shell-command be finally checked in? >> >> I think `async-shell-command' in >> http://thread.gmane.org/gmane.emacs.devel/99764/focus=101699 >> is just a starting point for implementing more powerful command >> that accepts more proposed options (like either to display the output >> buffer or not, etc.) > > Ok; then could this starting point be checked in? It is already useful. > > I think that before trying to extend it, it has to be correctly bound to M-& in the right places and without colliding with other M-& > Extensions can also wait because there are many and there isn't full consensus ([1]). So better get the base in first. > > [1] http://thread.gmane.org/gmane.emacs.devel/99764/focus=100293 Below is a ready patch submitted for verification before checking in: Index: lisp/bindings.el =================================================================== RCS file: /sources/emacs/emacs/lisp/bindings.el,v retrieving revision 1.219 diff -c -r1.219 bindings.el *** lisp/bindings.el 23 Jun 2009 07:39:43 -0000 1.219 --- lisp/bindings.el 30 Jun 2009 00:01:46 -0000 *************** *** 756,761 **** --- 760,766 ---- (define-key esc-map "!" 'shell-command) (define-key esc-map "|" 'shell-command-on-region) + (define-key esc-map "&" 'async-shell-command) (define-key ctl-x-map [right] 'next-buffer) (define-key ctl-x-map [C-right] 'next-buffer) Index: lisp/simple.el =================================================================== RCS file: /sources/emacs/emacs/lisp/simple.el,v retrieving revision 1.988 diff -c -r1.988 simple.el *** lisp/simple.el 13 Jun 2009 18:56:11 -0000 1.988 --- lisp/simple.el 30 Jun 2009 00:02:15 -0000 *************** *** 2054,2059 **** --- 2054,2076 ---- (or hist 'shell-command-history) args))) + (defun async-shell-command (command &optional output-buffer error-buffer) + "Execute string COMMAND asynchronously in background. + + Like `shell-command' but if COMMAND doesn't end in ampersand, adds `&' + surrounded by whitespace and executes the command asynchronously. + The output appears in the buffer `*Async Shell Command*'." + (interactive + (list + (read-shell-command "Async shell command: " nil nil + (and buffer-file-name + (file-relative-name buffer-file-name))) + current-prefix-arg + shell-command-default-error-buffer)) + (unless (string-match "&[ \t]*\\'" command) + (setq command (concat command " &"))) + (shell-command command output-buffer error-buffer)) + (defun shell-command (command &optional output-buffer error-buffer) "Execute string COMMAND in inferior shell; display output, if any. With prefix argument, insert the COMMAND's output at point. -- Juri Linkov http://www.jurta.org/emacs/