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: Wed, 23 Jul 2008 01:48:35 +0300 Organization: JURTA Message-ID: <87tzehd0ll.fsf@jurta.org> References: <87hcbkpo0e.fsf@gmail.com> <86y74wzeq1.fsf@lola.quinscape.zz> <874p7ifonh.fsf@jurta.org> <873amryzdu.fsf_-_@gmail.com> <87sku9hdkr.fsf@gmail.com> <87mykh1hpi.fsf@jurta.org> <87prpba6qj.fsf@gmail.com> <87abgfun32.fsf@jurta.org> <7dbe73ed0807221250v510e83b7u75dd271846704abb@mail.gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1216768164 31862 80.91.229.12 (22 Jul 2008 23:09:24 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 22 Jul 2008 23:09:24 +0000 (UTC) Cc: Daniel Clemente , emacs-devel@gnu.org To: "Mathias Dahl" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Jul 23 01:10:13 2008 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 1KLQzi-0002lG-FD for ged-emacs-devel@m.gmane.org; Wed, 23 Jul 2008 01:10:10 +0200 Original-Received: from localhost ([127.0.0.1]:39818 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KLQyp-0001oZ-4u for ged-emacs-devel@m.gmane.org; Tue, 22 Jul 2008 19:09:15 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KLQxy-0001PP-MM for emacs-devel@gnu.org; Tue, 22 Jul 2008 19:08:22 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KLQxy-0001P5-07 for emacs-devel@gnu.org; Tue, 22 Jul 2008 19:08:22 -0400 Original-Received: from [199.232.76.173] (port=45267 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KLQxx-0001P0-Rx for emacs-devel@gnu.org; Tue, 22 Jul 2008 19:08:21 -0400 Original-Received: from relay02.kiev.sovam.com ([62.64.120.197]:63749) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KLQxx-0004d4-BE for emacs-devel@gnu.org; Tue, 22 Jul 2008 19:08:21 -0400 Original-Received: from [83.170.232.243] (helo=smtp.svitonline.com) by relay02.kiev.sovam.com with esmtp (Exim 4.67) (envelope-from ) id 1KLQxr-000DqL-6K; Wed, 23 Jul 2008 02:08:15 +0300 In-Reply-To: <7dbe73ed0807221250v510e83b7u75dd271846704abb@mail.gmail.com> (Mathias Dahl's message of "Tue, 22 Jul 2008 21:50:09 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (x86_64-pc-linux-gnu) X-Scanner-Signature: cdcac4e9833a162831dcdc7415f73b92 X-DrWeb-checked: yes X-SpamTest-Envelope-From: juri@jurta.org X-SpamTest-Group-ID: 00000000 X-SpamTest-Header: Trusted X-SpamTest-Info: Profiles 4414 [July 23 2008] X-SpamTest-Info: {received from trusted relay: common white list} X-SpamTest-Info: {HEADERS: header Content-Type found without required header Content-Transfer-Encoding} X-SpamTest-Method: white ip list X-SpamTest-Rate: 10 X-SpamTest-Status: Trusted X-SpamTest-Status-Extended: trusted X-SpamTest-Version: SMTP-Filter Version 3.0.0 [0278], KAS30/Release X-detected-kernel: by monty-python.gnu.org: FreeBSD 6.x (1) 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:101257 Archived-At: >>>> We could even improve the command `dired-flag-garbage-files' to allow the >>>> user to modify its default regexp value in the minibuffer after typing `% &'. >>> >>> Maybe just if you prefix it with C-u ? >> >> C-u will make it inconsistent with a similar command % m (`dired-mark-files-regexp') >> where a prefix argument means to *unmark* files matching a regexp. > > So does % g, but % d does not. And I don't see that it should it be a > problem considering that `dired-flag-garbage-files' does not use the > prefix argument today. We decide what it should do. Right, so let's not worry about arguments of `dired-flag-garbage-files' now. So below is an initial version of a new command `dired-do-async-shell-command'. Its name is formed by analogy with the buffer name "*Async Shell Command*". Currently it simply adds & at the end of the asynchronous command. As for not asking a question "A command is running. Kill it? " I think this should be implemented with a new option in simple.el. Index: lisp/dired.el =================================================================== RCS file: /sources/emacs/emacs/lisp/dired.el,v retrieving revision 1.402 diff -c -r1.402 dired.el *** lisp/dired.el 19 Jul 2008 23:55:41 -0000 1.402 --- lisp/dired.el 22 Jul 2008 22:47:37 -0000 *************** *** 1194,1200 **** (define-key map "#" 'dired-flag-auto-save-files) (define-key map "." 'dired-clean-directory) (define-key map "~" 'dired-flag-backup-files) - (define-key map "&" 'dired-flag-garbage-files) ;; Upper case keys (except !) for operating on the marked files (define-key map "A" 'dired-do-search) (define-key map "C" 'dired-do-copy) --- 1195,1200 ---- *************** *** 1213,1218 **** --- 1213,1219 ---- (define-key map "X" 'dired-do-shell-command) (define-key map "Z" 'dired-do-compress) (define-key map "!" 'dired-do-shell-command) + (define-key map "&" 'dired-do-async-shell-command) ;; Comparison commands (define-key map "=" 'dired-diff) (define-key map "\M-=" 'dired-backup-diff) *************** *** 1240,1245 **** --- 1241,1247 ---- (define-key map "%H" 'dired-do-hardlink-regexp) (define-key map "%R" 'dired-do-rename-regexp) (define-key map "%S" 'dired-do-symlink-regexp) + (define-key map "%&" 'dired-flag-garbage-files) ;; Commands for marking and unmarking. (define-key map "*" nil) (define-key map "**" 'dired-mark-executables) Index: lisp/dired-aux.el =================================================================== RCS file: /sources/emacs/emacs/lisp/dired-aux.el,v retrieving revision 1.170 diff -c -r1.170 dired-aux.el *** lisp/dired-aux.el 6 May 2008 07:57:30 -0000 1.170 --- lisp/dired-aux.el 22 Jul 2008 22:43:45 -0000 *************** *** 490,495 **** --- 490,515 ---- (format prompt (dired-mark-prompt arg files)) nil nil))) + ;;;###autoload + (defun dired-do-async-shell-command (command &optional arg file-list) + "Run a shell command COMMAND on the marked files asynchronously. + + Like `dired-do-shell-command', but if COMMAND doesn't end in ampersand, + adds ampersand and executes the command asynchronously. + The output appears in the buffer `*Async Shell Command*'." + (interactive + (let ((files (dired-get-marked-files t current-prefix-arg))) + (list + ;; Want to give feedback whether this file or marked files are used: + (dired-read-shell-command "& on %s: " current-prefix-arg files) + current-prefix-arg + files))) + (unless (string-match "[*?][ \t]*\\'" command) + (setq command (concat command " *"))) + (unless (string-match "&[ \t]*\\'" command) + (setq command (concat command " &"))) + (dired-do-shell-command command arg file-list)) + ;; The in-background argument is only needed in Emacs 18 where ;; shell-command doesn't understand an appended ampersand `&'. ;;;###autoload -- Juri Linkov http://www.jurta.org/emacs/