From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tino Calancha Newsgroups: gmane.emacs.bugs 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) Message-ID: References: <87y42ysq5y.fsf@gmx.de> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset=US-ASCII X-Trace: blaine.gmane.org 1473596601 1466 195.159.176.226 (11 Sep 2016 12:23:21 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 11 Sep 2016 12:23:21 +0000 (UTC) User-Agent: Alpine 2.20 (DEB 67 2015-01-07) Cc: 24394@debbugs.gnu.org, Tino Calancha To: Michael Albinus Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Sep 11 14:23:16 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bj3n0-00084z-H3 for geb-bug-gnu-emacs@m.gmane.org; Sun, 11 Sep 2016 14:23:14 +0200 Original-Received: from localhost ([::1]:37551 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bj3my-00021u-GP for geb-bug-gnu-emacs@m.gmane.org; Sun, 11 Sep 2016 08:23:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43986) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bj3ms-00021p-GE for bug-gnu-emacs@gnu.org; Sun, 11 Sep 2016 08:23:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bj3mo-0004u5-8V for bug-gnu-emacs@gnu.org; Sun, 11 Sep 2016 08:23:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:58269) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bj3mo-0004u1-3M for bug-gnu-emacs@gnu.org; Sun, 11 Sep 2016 08:23:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bj3mn-00059p-T1 for bug-gnu-emacs@gnu.org; Sun, 11 Sep 2016 08:23:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 11 Sep 2016 12:23:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 24394 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 24394-submit@debbugs.gnu.org id=B24394.147359654419768 (code B ref 24394); Sun, 11 Sep 2016 12:23:01 +0000 Original-Received: (at 24394) by debbugs.gnu.org; 11 Sep 2016 12:22:24 +0000 Original-Received: from localhost ([127.0.0.1]:55981 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bj3mB-00058l-Hp for submit@debbugs.gnu.org; Sun, 11 Sep 2016 08:22:23 -0400 Original-Received: from mail-pf0-f181.google.com ([209.85.192.181]:36487) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bj3mA-00058a-Gh for 24394@debbugs.gnu.org; Sun, 11 Sep 2016 08:22:22 -0400 Original-Received: by mail-pf0-f181.google.com with SMTP id 128so43628437pfb.3 for <24394@debbugs.gnu.org>; Sun, 11 Sep 2016 05:22:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:date:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=LkNj/9n2Mtq9333AC+/WmFi+HAHNyeRa37BdQdL+6jk=; b=wXc+lLiMUQ3rX2KVMRacUABs+lmKwfy0/azI90XpqSehH9SvWbVILqWLiPPkE7UfLb 1V6pHp8A5GGkyQfqM4H6E+YJGt6QxHr1s/pVlpGJh1NXenWtds9XW6/9J4JIC7x/kbxc z+xq7E2r/bf8+t0BJY7siGNOAhxRfppANl9I4PdBxxAmORD12m/6KYe8KLJMFvGu2Tu4 aaQ7B8ieBNh5JpFpS4msQKjqHZU109Uy8zFB2R0h0rDqfqUPCDzCOASVh4bpkz9Uo7yd +Ys7Nxr69TAuSUk3GhvDQbt0RCg5SBlIKT+jpfGHc0DqMNUC7c8/H73lctAM1i+05wyg NGOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:date:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=LkNj/9n2Mtq9333AC+/WmFi+HAHNyeRa37BdQdL+6jk=; b=nESncI35RNgqnr5U88vDRXVKvYZK1boJwL+cdICxvuIMDF89e5k2MCUGdQ9MZ5yWUT ieSCne7CVUXatsD4y3NU8VArRtoL3DE2XdxpwFfwv7tSpc8wOqfWKKKBEvwb52/Ub5by 9jpwwekTxQoCVmexMDNGyv/nc2h+GvsYboCnYQn2YQUl7G6VjVYEftku7+qOky5hqhHH wa9gmYTthbwqM08NVgYdzZ8qMt8wiIK55Frpd7Evdjpu6BzPAm8/uEns0PDDHwLAvS6z r2Yh3j61rx2OaCT5OshPw7gY1QBDVggi0ZuPo/1KtSMPh7D1ta3EvnKwsrH1vEKatxDy RpLA== X-Gm-Message-State: AE9vXwPi5KjNGtIdYpu/vkikA/BIp8r8Ez7Za2v1urSOE7NrLMhEoGOAypsJCL8xYIsApA== X-Received: by 10.98.198.147 with SMTP id x19mr20248478pfk.77.1473596536849; Sun, 11 Sep 2016 05:22:16 -0700 (PDT) Original-Received: from calancha-pc (57.92.100.220.dy.bbexcite.jp. [220.100.92.57]) by smtp.gmail.com with ESMTPSA id s12sm17468742pfj.73.2016.09.11.05.22.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 11 Sep 2016 05:22:16 -0700 (PDT) X-Google-Original-From: Tino Calancha X-X-Sender: calancha@calancha-pc In-Reply-To: <87y42ysq5y.fsf@gmx.de> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:123167 Archived-At: 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 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