all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Patch of shell-command-to-string in simple for tramp support
@ 2018-01-25 12:11 Shuguang Sun
  2018-01-25 13:08 ` Michael Albinus
  0 siblings, 1 reply; 5+ messages in thread
From: Shuguang Sun @ 2018-01-25 12:11 UTC (permalink / raw)
  To: emacs-devel


[-- 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.

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

end of thread, other threads:[~2018-01-25 14:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-25 12:11 Patch of shell-command-to-string in simple for tramp support Shuguang Sun
2018-01-25 13:08 ` Michael Albinus
2018-01-25 14:11   ` Shuguang Sun
2018-01-25 14:31     ` Michael Albinus
2018-01-25 14:12   ` Stefan Monnier

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.