all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Shuguang Sun <shuguang@gmail.com>
To: emacs-devel@gnu.org
Subject: Patch of shell-command-to-string in simple for tramp support
Date: Thu, 25 Jan 2018 20:11:08 +0800	[thread overview]
Message-ID: <CACspjXcSqjCj_H4WTH8J0Fs6foP5FX5AwX+CkmxZ2TAQ-fXZhw@mail.gmail.com> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 449 bytes --]

Hi,

The shell-command-to-string calls shell-file-name directly and it doesn't
work in the case of local Windows and remoter Unix. I borrow the some code
from shell.el and make a patch to simple.el.

Example: in find-file-in-project, shell-command-to-string was called to get
the list of filenames. If it is in a remote directry via tramp, it will put
error message c:/.../cmdproxy.exe not found.
The patch solves the issue.

Best Regards,
Shuguang

[-- Attachment #1.2: Type: text/html, Size: 583 bytes --]

[-- Attachment #2: simple.el.diff --]
[-- Type: text/plain, Size: 2217 bytes --]

diff --git a/lisp/simple.el b/lisp/simple.el
index e51bc132a6..1c3c1f8a9b 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -3844,7 +3844,42 @@ shell-command-to-string
   (with-output-to-string
     (with-current-buffer
       standard-output
-      (process-file shell-file-name nil t nil shell-command-switch command))))
+      (when (file-remote-p default-directory)
+        ;; Borrow from shell in shell.el
+        ;; Apply connection-local variables.
+        (hack-connection-local-variables-apply
+         `(:application tramp
+                        :protocol ,(file-remote-p default-directory 'method)
+                        :user ,(file-remote-p default-directory 'user)
+                        :machine ,(file-remote-p default-directory 'host)))
+
+        ;; On remote hosts, the local `shell-file-name' might be useless.
+        (if (and (called-interactively-p 'any)
+                 (null explicit-shell-file-name)
+                 (null (getenv "ESHELL")))
+            (set (make-local-variable 'explicit-shell-file-name)
+                 (file-local-name
+                  (expand-file-name
+                   (read-file-name
+                    "Remote shell path: " default-directory shell-file-name
+                    t shell-file-name))))))
+
+      (unless (comint-check-proc standard-output)
+        (let* ((prog (or explicit-shell-file-name
+                         (getenv "ESHELL") shell-file-name))
+               ;; we can't use "-i"
+               ;; (name (file-name-nondirectory prog))
+               ;; (xargs-name (intern-soft (concat "explicit-" name "-args")))
+               )
+          (process-file prog nil t nil
+                        ;; here we can't use "-i"
+                        ;; (if (and xargs-name (boundp xargs-name))
+                        ;;     (mapconcat 'identity (symbol-value xargs-name) " ")
+                        ;;   shell-command-switch)
+                        shell-command-switch
+                        command)
+          ))
+      )))

 (defun process-file (program &optional infile buffer display &rest args)
   "Process files synchronously in a separate process.

             reply	other threads:[~2018-01-25 12:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-25 12:11 Shuguang Sun [this message]
2018-01-25 13:08 ` Patch of shell-command-to-string in simple for tramp support Michael Albinus
2018-01-25 14:11   ` Shuguang Sun
2018-01-25 14:31     ` Michael Albinus
2018-01-25 14:12   ` Stefan Monnier

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=CACspjXcSqjCj_H4WTH8J0Fs6foP5FX5AwX+CkmxZ2TAQ-fXZhw@mail.gmail.com \
    --to=shuguang@gmail.com \
    --cc=emacs-devel@gnu.org \
    /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.