all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#18096: 24.3.92; async shell command and a busy buffer leads to error
@ 2014-07-24 12:13 Nicolas Richard
  2014-07-27 23:53 ` Juri Linkov
  0 siblings, 1 reply; 3+ messages in thread
From: Nicolas Richard @ 2014-07-24 12:13 UTC (permalink / raw
  To: 18096


Running the following and answering "yes" to the prompt leads to an error:

(let ((b (get-buffer-create "Some command")))
  (shell-command "sleep 1 &" b)
  (shell-command ":&" b))

Debugger entered--Lisp error: (wrong-type-argument stringp #<buffer Some command>)
  generate-new-buffer-name(#<buffer Some command>)
  generate-new-buffer(#<buffer Some command>)
  (setq buffer (generate-new-buffer (or output-buffer "*Async Shell Command*")))
  [hand-edited]
  shell-command(":&" #<buffer Some command>)

I suggest the following in order to have a better error message :

--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -2904,7 +2904,8 @@ the use of a shell (with its need to quote arguments)."
 		      (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.  Use a new buffer? ")
+		    (if (and (stringp output-buffer)
+                             (yes-or-no-p "A command is running in the default buffer.  Use a new buffer? "))
 			(setq buffer (generate-new-buffer
 				      (or output-buffer "*Async Shell Command*")))
 		      (error "Shell command in progress")))

-- 
Nico.





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#18096: 24.3.92; async shell command and a busy buffer leads to error
  2014-07-24 12:13 bug#18096: 24.3.92; async shell command and a busy buffer leads to error Nicolas Richard
@ 2014-07-27 23:53 ` Juri Linkov
  2014-11-09  6:57   ` Nicolas Richard
  0 siblings, 1 reply; 3+ messages in thread
From: Juri Linkov @ 2014-07-27 23:53 UTC (permalink / raw
  To: Nicolas Richard; +Cc: 18096

> --- a/lisp/simple.el
> +++ b/lisp/simple.el
> @@ -2904,7 +2904,8 @@ the use of a shell (with its need to quote arguments)."
>  		      (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.  Use a new buffer? ")
> +		    (if (and (stringp output-buffer)
> +                             (yes-or-no-p "A command is running in the default buffer.  Use a new buffer? "))
>  			(setq buffer (generate-new-buffer
>  				      (or output-buffer "*Async Shell Command*")))
>  		      (error "Shell command in progress")))

This will ignore the user customization in `async-shell-command-buffer'
if the user want it to ask a question whether to create a new buffer.
More tolerating would be trying to get a new buffer name even when
the given argument is a buffer:

=== modified file 'lisp/simple.el'
--- lisp/simple.el	2014-07-08 08:27:45 +0000
+++ lisp/simple.el	2014-07-27 23:44:20 +0000
@@ -2986,12 +2986,14 @@ (defun shell-command (command &optional
 		    ;; If will create a new buffer, query first.
 		    (if (yes-or-no-p "A command is running in the default buffer.  Use a new buffer? ")
 			(setq buffer (generate-new-buffer
-				      (or output-buffer "*Async Shell Command*")))
+				      (or (and (bufferp output-buffer) (buffer-name output-buffer))
+					  output-buffer "*Async Shell Command*")))
 		      (error "Shell command in progress")))
 		   ((eq async-shell-command-buffer 'new-buffer)
 		    ;; It will create a new buffer.
 		    (setq buffer (generate-new-buffer
-				  (or output-buffer "*Async Shell Command*"))))
+				  (or (and (bufferp output-buffer) (buffer-name output-buffer))
+				      output-buffer "*Async Shell Command*"))))
 		   ((eq async-shell-command-buffer 'confirm-rename-buffer)
 		    ;; If will rename the buffer, query first.
 		    (if (yes-or-no-p "A command is running in the default buffer.  Rename it? ")







^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#18096: 24.3.92; async shell command and a busy buffer leads to error
  2014-07-27 23:53 ` Juri Linkov
@ 2014-11-09  6:57   ` Nicolas Richard
  0 siblings, 0 replies; 3+ messages in thread
From: Nicolas Richard @ 2014-11-09  6:57 UTC (permalink / raw
  To: Juri Linkov; +Cc: 18096@debbugs.gnu.org

[-- Attachment #1: Type: text/plain, Size: 98 bytes --]

Hi Juri,

Sorry I realize I had forgotten to answer you.
Thanks for solving it.


Nicolas.

[-- Attachment #2: Type: text/html, Size: 1277 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-11-09  6:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-24 12:13 bug#18096: 24.3.92; async shell command and a busy buffer leads to error Nicolas Richard
2014-07-27 23:53 ` Juri Linkov
2014-11-09  6:57   ` Nicolas Richard

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.