[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: & and M-& to run programs asynchronously
From: |
Juri Linkov |
Subject: |
Re: & and M-& to run programs asynchronously |
Date: |
Wed, 23 Jul 2008 01:48:35 +0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (x86_64-pc-linux-gnu) |
>>>> 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/
- Re: & and M-& to run programs asynchronously, (continued)
Re: & and M-& to run programs asynchronously, Juri Linkov, 2008/07/06
Re: & and M-& to run programs asynchronously, Daniel Clemente, 2008/07/16
- Re: & and M-& to run programs asynchronously, Juri Linkov, 2008/07/16
- Re: & and M-& to run programs asynchronously, Daniel Clemente, 2008/07/18
- Re: & and M-& to run programs asynchronously, Juri Linkov, 2008/07/18
- Re: & and M-& to run programs asynchronously, Mathias Dahl, 2008/07/22
- Re: & and M-& to run programs asynchronously,
Juri Linkov <=
- Re: & and M-& to run programs asynchronously, Daniel Clemente, 2008/07/29
- Re: & and M-& to run programs asynchronously, Juri Linkov, 2008/07/29
- Re: & and M-& to run programs asynchronously, Chong Yidong, 2008/07/31
- Re: & and M-& to run programs asynchronously, Juri Linkov, 2008/07/31