Subject: bug#34798: 27.0.50; xclip issue in tramp mode

From: Stefan Monnier <[email-masked]>
Date: Mon, 11 Mar 2019 16:16:00 -0400

Ergus <[email-masked]> writes:

> Hi:
>
> There is an issue in xclip-mode when using tramp
>
> emacs -q -nw
> C-x C-f /ssh:user@host:file RET
> M-x load-file RET xclip.el RET
> M-x xclip-mode RET
> abcd C-SPC C-a M-w C-e RET   <-1
> C-y                          <-2
> RET                          <-3
> C-y M-y RET                  <-4
> S-C-v                        <-5
>
> Produces this output:
> abcd                         <-1
> sh: xclip: command not found <-2

Duh!  I pushed the patch below which seems to fix it for me.

> abcd                         <-4
> abcd                         <-5
>
> As you can see the 2) yanks the error message including a new line.
> But 4) (emacs yank + yank-pop) yanks the text and 5 (xterm-paste) too.

I think these were side-effects of the previous problem.
xclip-1.8 (to appear soonish) will include this fix.

        Stefan

diff --git a/packages/xclip/xclip.el b/packages/xclip/xclip.el
index b142475b5..b1686e14d 100644
--- a/packages/xclip/xclip.el
+++ b/packages/xclip/xclip.el
@@ -1,6 +1,6 @@
 ;;; xclip.el --- Copy&paste GUI clipboard from text terminal  -*- lexical-binding:t -*-
 
-;; Copyright (C) 2007, 2012, 2013, 2017, 2018  Free Software Foundation, Inc.
+;; Copyright (C) 2007-2019  Free Software Foundation, Inc.
 
 ;; Author: Leo Liu <[email-masked]>
 ;; Keywords: convenience, tools
@@ -144,21 +144,21 @@ See also `x-set-selection'."
       (pcase xclip-method
         (`pbpaste
          (when (memq type '(clipboard CLIPBOARD))
-           (process-file xclip-program nil standard-output nil
+           (call-process xclip-program nil standard-output nil
                          "-Prefer" "txt")))
         (`getclip
          (when (memq type '(clipboard CLIPBOARD))
-           (process-file xclip-program nil standard-output nil)))
+           (call-process xclip-program nil standard-output nil)))
         (`xclip
          (when (getenv "DISPLAY")
-           (process-file xclip-program nil standard-output nil
+           (call-process xclip-program nil standard-output nil
                          "-o" "-selection" (symbol-name type))))
         (`xsel
          (when (and (getenv "DISPLAY")
                     (memq type '(clipboard CLIPBOARD
                                  primary PRIMARY
                                  secondary SECONDARY)))
-           (process-file xclip-program nil standard-output nil
+           (call-process xclip-program nil standard-output nil
                          "-o" (concat "--" (downcase (symbol-name type))))))
         (method (error "Unknown `xclip-method': %S" method))))))
 
@@ -281,7 +281,7 @@ Emacs-NN and is then later run by Emacs>NN."
       (or clip-text
           (when (and (memq xclip-method '(xsel xclip)) (getenv "DISPLAY"))
             (let ((primary-text (with-output-to-string
-                                  (process-file xclip-program nil
+                                  (call-process xclip-program nil
                                                 standard-output nil "-o"))))
               (setq primary-text
                     (cond               ; Check primary selection.