GNU bug report logs -
#4719
23.1; M-& to run commands asynchronously (async-shell-command)
Previous Next
Reported by: dcl441-bugs <at> yahoo.com
Date: Wed, 14 Oct 2009 00:20:04 UTC
Severity: wishlist
Merged with 8023
Done: Juri Linkov <juri <at> jurta.org>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 4719 in the body.
You can then email your comments to 4719 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#4719
; Package
emacs
.
(Wed, 14 Oct 2009 00:20:04 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
dcl441-bugs <at> yahoo.com
:
New bug report received and forwarded. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
(Wed, 14 Oct 2009 00:20:04 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):
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-&.
Information forwarded
to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#4719
; Package
emacs
.
(Wed, 14 Oct 2009 03:10:06 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Stefan Monnier <monnier <at> iro.umontreal.ca>
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
(Wed, 14 Oct 2009 03:10:07 GMT)
Full text and
rfc822 format available.
Message #10 received at 4719 <at> emacsbugs.donarmstrong.com (full text, mbox):
> I propose to add a new function, async-shell-command, bound to M-&,
We have that already now, don't we?
Stefan
Information forwarded
to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#4719
; Package
emacs
.
(Wed, 14 Oct 2009 08:00:05 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
dcl441-bugs <at> yahoo.com
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
(Wed, 14 Oct 2009 08:00:05 GMT)
Full text and
rfc822 format available.
Message #15 received at 4719 <at> emacsbugs.donarmstrong.com (full text, mbox):
> We have that already now, don't we?
Yes. I didn't check 23.2, sorry.
This bug can be closed.
Information forwarded
to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#4719
; Package
emacs
.
(Wed, 14 Oct 2009 20:50:16 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Juri Linkov <juri <at> jurta.org>
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
(Wed, 14 Oct 2009 20:50:17 GMT)
Full text and
rfc822 format available.
Message #20 received at 4719 <at> emacsbugs.donarmstrong.com (full text, mbox):
>> 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/
Severity set to 'wishlist' from 'normal'
Request was from
Glenn Morris <rgm <at> gnu.org>
to
control <at> emacsbugs.donarmstrong.com
.
(Thu, 15 Oct 2009 06:30:04 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#4719
; Package
emacs
.
(Fri, 16 Oct 2009 06:55:08 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
dcl441-bugs <at> yahoo.com
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
(Fri, 16 Oct 2009 06:55:08 GMT)
Full text and
rfc822 format available.
Message #27 received at 4719 <at> emacsbugs.donarmstrong.com (full text, mbox):
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
Forcibly Merged 4719 8023.
Request was from
Juri Linkov <juri <at> jurta.org>
to
control <at> debbugs.gnu.org
.
(Tue, 17 Jul 2012 18:56:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#4719
; Package
emacs
.
(Tue, 17 Jul 2012 19:09:02 GMT)
Full text and
rfc822 format available.
Message #32 received at 4719 <at> debbugs.gnu.org (full text, mbox):
> 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
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#4719
; Package
emacs
.
(Sat, 28 Jul 2012 15:27:01 GMT)
Full text and
rfc822 format available.
Message #35 received at 4719 <at> debbugs.gnu.org (full text, mbox):
Juri Linkov <juri <at> 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.
Reply sent
to
Juri Linkov <juri <at> jurta.org>
:
You have taken responsibility.
(Sun, 29 Jul 2012 00:23:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
dcl441-bugs <at> yahoo.com
:
bug acknowledged by developer.
(Sun, 29 Jul 2012 00:23:03 GMT)
Full text and
rfc822 format available.
Message #40 received at 4719-done <at> debbugs.gnu.org (full text, mbox):
>> 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.
Reply sent
to
Juri Linkov <juri <at> jurta.org>
:
You have taken responsibility.
(Sun, 29 Jul 2012 00:23:03 GMT)
Full text and
rfc822 format available.
Notification sent
to
jidanni <at> jidanni.org
:
bug acknowledged by developer.
(Sun, 29 Jul 2012 00:23:03 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sun, 26 Aug 2012 11:24:03 GMT)
Full text and
rfc822 format available.
This bug report was last modified 11 years and 266 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.