* bug#4719: 23.1; M-& to run commands asynchronously (async-shell-command)
@ 2009-10-14 0:10 Daniel Clemente
2009-10-14 3:01 ` Stefan Monnier
0 siblings, 1 reply; 8+ messages in thread
From: Daniel Clemente @ 2009-10-14 0:10 UTC (permalink / raw)
To: bug-gnu-emacs
I propose to add a new function, async-shell-command, bound to M-&, which in analogous to shell-command (bound to M-!) but executes the command in the background (as if you had written an ampersand at the end of M-!).
Both functions would respectively correspond to keys ! and & in dired, only that ! and & work only in dired but M-! and M-& would be global (work everywhere).
The code is in this message in an old thread:
http://article.gmane.org/gmane.emacs.devel/111825
There are still some details to decide: how many buffers to open, where to direct STDOUT, whether output should be visible, …
Some modes should be checked since they might be using M-&.
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#4719: 23.1; M-& to run commands asynchronously (async-shell-command)
2009-10-14 0:10 bug#4719: 23.1; M-& to run commands asynchronously (async-shell-command) Daniel Clemente
@ 2009-10-14 3:01 ` Stefan Monnier
2009-10-14 7:50 ` Daniel Clemente
0 siblings, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2009-10-14 3:01 UTC (permalink / raw)
To: dcl441-bugs; +Cc: 4719
> I propose to add a new function, async-shell-command, bound to M-&,
We have that already now, don't we?
Stefan
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#4719: 23.1; M-& to run commands asynchronously (async-shell-command)
2009-10-14 3:01 ` Stefan Monnier
@ 2009-10-14 7:50 ` Daniel Clemente
2009-10-14 20:41 ` Juri Linkov
0 siblings, 1 reply; 8+ messages in thread
From: Daniel Clemente @ 2009-10-14 7:50 UTC (permalink / raw)
To: Stefan Monnier; +Cc: 4719
> We have that already now, don't we?
Yes. I didn't check 23.2, sorry.
This bug can be closed.
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#4719: 23.1; M-& to run commands asynchronously (async-shell-command)
2009-10-14 7:50 ` Daniel Clemente
@ 2009-10-14 20:41 ` Juri Linkov
2009-10-16 6:48 ` Daniel Clemente
0 siblings, 1 reply; 8+ messages in thread
From: Juri Linkov @ 2009-10-14 20:41 UTC (permalink / raw)
To: dcl441-bugs; +Cc: 4719
>> We have that already now, don't we?
>
> Yes. I didn't check 23.2, sorry.
> This bug can be closed.
I'm not sure this can be closed, because in your original report you wrote:
There are still some details to decide: how many buffers to open,
where to direct STDOUT, whether output should be visible, …
Do you expect this to be implemented under this feature request?
--
Juri Linkov
http://www.jurta.org/emacs/
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#4719: 23.1; M-& to run commands asynchronously (async-shell-command)
2009-10-14 20:41 ` Juri Linkov
@ 2009-10-16 6:48 ` Daniel Clemente
2012-07-17 18:57 ` Juri Linkov
0 siblings, 1 reply; 8+ messages in thread
From: Daniel Clemente @ 2009-10-16 6:48 UTC (permalink / raw)
To: Juri Linkov; +Cc: 4719
Ok, let's see what's missing to do.
I saw following topics being discussed (summary here): http://article.gmane.org/gmane.emacs.devel/100293
- command can be in background or not: we have this
- the output might be visible or not
- a new buffer might be spawned for each process or not
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#4719: 23.1; M-& to run commands asynchronously (async-shell-command)
2009-10-16 6:48 ` Daniel Clemente
@ 2012-07-17 18:57 ` Juri Linkov
2012-07-28 15:19 ` Chong Yidong
0 siblings, 1 reply; 8+ messages in thread
From: Juri Linkov @ 2012-07-17 18:57 UTC (permalink / raw)
To: dcl441-bugs; +Cc: 4719
> Ok, let's see what's missing to do.
> I saw following topics being discussed (summary here):
> http://article.gmane.org/gmane.emacs.devel/100293
>
> - command can be in background or not: we have this
> - the output might be visible or not
> - a new buffer might be spawned for each process or not
The problem with the design and implementation of this feature is that
there is too wide range of opinions and wishes.
So I propose a minimal change that just removes the current annoyance
where async-shell-command asks to kill the buffer instead of doing
something more constructive like creating a new buffer for running
another asynchronous command.
This is implemented in the patch below.
As for displaying the output buffer or not, I think this is the
responsibility of the window configuration system to decide whether
and where to display the output buffer.
=== modified file 'lisp/simple.el'
--- lisp/simple.el 2012-07-17 18:40:15 +0000
+++ lisp/simple.el 2012-07-17 18:55:25 +0000
@@ -2244,6 +2316,24 @@ (defun read-shell-command (prompt &optio
(or hist 'shell-command-history)
args)))
+(defcustom async-shell-command-buffer 'confirm-new-buffer
+ "What to do when the output buffer is used by another shell command.
+This option specifies how to resolve the conflict where a new command
+want to direct its output to the buffer `*Async Shell Command*',
+but this buffer is already taken by another running shell command."
+ :type '(choice (const :tag "Confirm killing of running command"
+ confirm-kill-process)
+ (const :tag "Confirm renaming of existing buffer"
+ confirm-rename-buffer)
+ (const :tag "Confirm creation of a new buffer"
+ confirm-new-buffer)
+ (const :tag "Rename the existing buffer"
+ rename-buffer)
+ (const :tag "Create a new buffer"
+ new-buffer))
+ :group 'shell
+ :version "24.2")
+
(defun async-shell-command (command &optional output-buffer error-buffer)
"Execute string COMMAND asynchronously in background.
@@ -2398,12 +2488,40 @@ (defun shell-command (command &optional
proc)
;; Remove the ampersand.
(setq command (substring command 0 (match-beginning 0)))
- ;; If will kill a process, query first.
+ ;; Ask the user what to do with already running process.
(setq proc (get-buffer-process buffer))
- (if proc
+ (when proc
+ (cond
+ ((eq async-shell-command-buffer 'confirm-kill-process)
+ ;; If will kill a process, query first.
(if (yes-or-no-p "A command is running. Kill it? ")
(kill-process proc)
(error "Shell command in progress")))
+ ((eq async-shell-command-buffer 'confirm-rename-buffer)
+ ;; If will create a new buffer, query first.
+ (if (yes-or-no-p "A command is running. Rename its output buffer before running a new command? ")
+ (progn
+ (with-current-buffer buffer
+ (rename-uniquely))
+ (setq buffer (get-buffer-create
+ (or output-buffer "*Async Shell Command*"))))
+ (error "Shell command in progress")))
+ ((eq async-shell-command-buffer 'confirm-new-buffer)
+ ;; If will create a new buffer, query first.
+ (if (yes-or-no-p "A command is running in the default buffer. Run in a new buffer? ")
+ (setq buffer (generate-new-buffer
+ (or output-buffer "*Async Shell Command*")))
+ (error "Shell command in progress")))
+ ((eq async-shell-command-buffer 'rename-buffer)
+ ;; It will create a new buffer.
+ (with-current-buffer buffer
+ (rename-uniquely))
+ (setq buffer (get-buffer-create
+ (or output-buffer "*Async Shell Command*"))))
+ ((eq async-shell-command-buffer 'new-buffer)
+ ;; It will create a new buffer.
+ (setq buffer (generate-new-buffer
+ (or output-buffer "*Async Shell Command*"))))))
(with-current-buffer buffer
(setq buffer-read-only nil)
;; Setting buffer-read-only to nil doesn't suffice
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#4719: 23.1; M-& to run commands asynchronously (async-shell-command)
2012-07-17 18:57 ` Juri Linkov
@ 2012-07-28 15:19 ` Chong Yidong
2012-07-29 0:04 ` Juri Linkov
0 siblings, 1 reply; 8+ messages in thread
From: Chong Yidong @ 2012-07-28 15:19 UTC (permalink / raw)
To: Juri Linkov; +Cc: dcl441-bugs, 4719
Juri Linkov <juri@jurta.org> writes:
> The problem with the design and implementation of this feature is that
> there is too wide range of opinions and wishes.
>
> So I propose a minimal change that just removes the current annoyance
> where async-shell-command asks to kill the buffer instead of doing
> something more constructive like creating a new buffer for running
> another asynchronous command.
>
> This is implemented in the patch below.
Patch looks fine to me.
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#4719: 23.1; M-& to run commands asynchronously (async-shell-command)
2012-07-28 15:19 ` Chong Yidong
@ 2012-07-29 0:04 ` Juri Linkov
0 siblings, 0 replies; 8+ messages in thread
From: Juri Linkov @ 2012-07-29 0:04 UTC (permalink / raw)
To: Chong Yidong; +Cc: dcl441-bugs, 4719-done
>> So I propose a minimal change that just removes the current annoyance
>> where async-shell-command asks to kill the buffer instead of doing
>> something more constructive like creating a new buffer for running
>> another asynchronous command.
>>
>> This is implemented in the patch below.
>
> Patch looks fine to me.
Installed and closed.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2012-07-29 0:04 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-14 0:10 bug#4719: 23.1; M-& to run commands asynchronously (async-shell-command) Daniel Clemente
2009-10-14 3:01 ` Stefan Monnier
2009-10-14 7:50 ` Daniel Clemente
2009-10-14 20:41 ` Juri Linkov
2009-10-16 6:48 ` Daniel Clemente
2012-07-17 18:57 ` Juri Linkov
2012-07-28 15:19 ` Chong Yidong
2012-07-29 0:04 ` Juri Linkov
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).