all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Tino Calancha <tino.calancha@gmail.com>
To: Michael Albinus <michael.albinus@gmx.de>
Cc: 24394@debbugs.gnu.org, Tino Calancha <tino.calancha@gmail.com>
Subject: bug#24394: 25.1.50; (find-file "/sudo::") ignores async-shell-command-buffer settings
Date: Sun, 11 Sep 2016 21:22:12 +0900 (JST)	[thread overview]
Message-ID: <alpine.DEB.2.20.1609112121520.31648@calancha-pc> (raw)
In-Reply-To: <87y42ysq5y.fsf@gmx.de>


On Sun, 11 Sep 2016, Michael Albinus wrote:

Hi Michael,
thank you for your comprehensive answer.

> Well, this comment is more than 8 years old, and it is not true anymore
> (I've just tested). I don't remember when this was fixed, but so what 
...
Great!  It's very good to heard that in principle tramp could support
>1 async processes.

> However, I'm kind of reluctant to fix this in
> `tramp-handle-shell-command'. The respective code in `shell-command'
> spans over ~40 lines, and I don't believe Tramp shall simply copy those
> lines (and other details not handled in Tramp yet). It's even
> questionable that Tramp shall offer an own handler for `shell-command'.
It might has sense to refactor that part into a new function (see patch 
below).
The tramp could use this new function which just use the variable
`async-shell-command-buffer'.  Other things like 
`shell-command-dont-erase-buffer'
can perfectly be ignored by tramp: they are still not well established.

> The reason why Tramp does this is the use of `shell-file-name' and
> `shell-command-switch'. They keep host local values, for remote
> connections other values are needed. It is a long standing request, that
> Tramp shall offer connection local variables, which carry different
> values for different remote hosts. If we would have such a mechanism,
> `shell-command' could use `process-file' and `start-file-process', and 
it
> would not need to call a file name handler anymore.
>
> And this error would go away.
That sounds like the ultimate solution.
A partial solution could be to allow running >1 async commands as root
in the local machine _only_.  Then, `shell-file-name' and
`shell-command-switch' are the same.
Sometimes i need to execute more than 1 process with root priviledges in
my local machine: i do this using several terminals.
Running all the processes inside Emacs would be nicer.


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
From ea08797362e9f4e02746e12229af7f160f7b4251 Mon Sep 17 00:00:00 2001
From: Tino Calancha <tino.calancha@gmail.com>
Date: Sun, 11 Sep 2016 20:49:56 +0900
Subject: [PATCH] shell-command: Refactor buffer creation for async cmd

* lisp/simple.el (async-shell-command-handle-multi-process):
New defun; handle the creation of a new asynchronous shell command
according with 'async-shell-command-buffer'.
(shell-command): Use it.
---
  lisp/simple.el | 91 
++++++++++++++++++++++++++++++++++++----------------------
  1 file changed, 57 insertions(+), 34 deletions(-)

diff --git a/lisp/simple.el b/lisp/simple.el
index 04a525c..3d0c579 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -3311,6 +3311,59 @@ async-shell-command
      (setq command (concat command " &")))
    (shell-command command output-buffer error-buffer))

+(defun async-shell-command-handle-multi-process (proc buffer 
output-buffer)
+  "Handle > 1 async shell commands according with 
`async-shell-command-buffer'.
+PROC is the process with buffer *Async Shell Command*.
+BUFFER is the buffer associated to the new async shell command.
+OUTPUT-BUFFER, if non-nil, says to put the output in some other buffer.
+Return BUFFER."
+  (pcase async-shell-command-buffer
+    ('confirm-kill-process
+      ;; If will kill a process, query first.
+      (if (yes-or-no-p
+           "A command is running in the default buffer.  Kill it? ")
+          (kill-process proc)
+        (error "Shell command in progress")))
+    ('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? ")
+          (setq buffer (generate-new-buffer
+                        (or (and (or (bufferp output-buffer)
+                                     (stringp output-buffer))
+                                 (buffer-name output-buffer))
+                            "*Async Shell Command*")))
+        (error "Shell command in progress")))
+    ('new-buffer
+      ;; It will create a new buffer.
+      (setq buffer (generate-new-buffer
+                    (or (and (or (bufferp output-buffer)
+                                 (stringp output-buffer))
+                             (buffer-name output-buffer))
+                        "*Async Shell Command*"))))
+    ('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? ")
+          (progn
+            (with-current-buffer buffer
+              (rename-uniquely))
+            (setq buffer (get-buffer-create
+                          (or (and (or (bufferp output-buffer)
+                                       (stringp output-buffer))
+                                   output-buffer)
+                              "*Async Shell Command*"))))
+        (error "Shell command in progress")))
+    ('rename-buffer
+      ;; It will rename the buffer.
+      (with-current-buffer buffer
+        (rename-uniquely))
+      (setq buffer (get-buffer-create
+                    (or (and (or (bufferp output-buffer)
+                                 (stringp output-buffer))
+                             output-buffer)
+                        "*Async Shell Command*"))))) buffer)
+
  (defun shell-command (command &optional output-buffer error-buffer)
    "Execute string COMMAND in inferior shell; display output, if any.
  With prefix argument, insert the COMMAND's output at point.
@@ -3442,40 +3495,10 @@ shell-command
  		(setq command (substring command 0 (match-beginning 0)))
  		;; Ask the user what to do with already running process.
  		(setq proc (get-buffer-process buffer))
-		(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 in the default 
buffer.  Kill it? ")
-			(kill-process proc)
-		      (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? ")
-			(setq buffer (generate-new-buffer
-				      (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 (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? ")
-			(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 'rename-buffer)
-		    ;; It will rename the buffer.
-		    (with-current-buffer buffer
-		      (rename-uniquely))
-		    (setq buffer (get-buffer-create
-				  (or output-buffer "*Async Shell 
Command*"))))))
+                (when proc
+                  (setq buffer
+                        (async-shell-command-handle-multi-process
+                         proc output-buffer buffer)))
  		(with-current-buffer buffer
  		  (display-buffer buffer '(nil (allow-no-window . t)))
                    (shell-command--save-pos-or-erase)
-- 
2.9.3

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

In GNU Emacs 25.1.50.1 (x86_64-pc-linux-gnu, GTK+ Version 3.21.5)
  of 2016-09-11 built on calancha-pc
Repository revision: 5fd1f7f931163ddf04f0ba0c362840fc91fba54a







  reply	other threads:[~2016-09-11 12:22 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-08 14:39 bug#24394: 25.1.50; (find-file "/sudo::") ignores async-shell-command-buffer settings Tino Calancha
2016-09-08 15:54 ` Tino Calancha
2016-09-11 10:10 ` Michael Albinus
2016-09-11 12:22   ` Tino Calancha [this message]
2016-09-12 10:07     ` Michael Albinus
2016-09-12 12:21       ` Tino Calancha
2019-03-22 13:45       ` Michael Albinus
2019-03-23 19:49         ` Tino Calancha
2019-03-24 12:43           ` Michael Albinus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.20.1609112121520.31648@calancha-pc \
    --to=tino.calancha@gmail.com \
    --cc=24394@debbugs.gnu.org \
    --cc=michael.albinus@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.