emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

elpa xclip 1.11.1: copying from emacs GUI hangs emacs terminal


From: pinmacs
Subject: elpa xclip 1.11.1: copying from emacs GUI hangs emacs terminal
Date: Mon, 9 Dec 2024 17:59:32 +0100

Hi,

I first contacted Leo, the maintainer privately, and she proposed me to discuss with you guys here broadly.

Context: I am a Debian GNU/Linux 12 (bookworm) user that runs the i3wm.org desktop, but I use emacs compiled on my own [0] from banch emacs-30 commit 44c2614, I think this is unrelated for the issue because I am having the issue since long time but recently I dedicated some hours to see if I could fix it:

Bug report: When I run an emacsclient sessions through X11 (named later, x11 emacs), and I copy (with common M-w) some text to the X11 clipboard and I paste (with common C-y) X11 clipboard it with Alacritty terminal (emacs running on terminal), then emacs hangs and I need to press C-g several times to kill the process that is being run and I don't get the clipboard content.

More details:

Everything else works perfectly, my config is simple on that matter:

#+begin_src emacs-lisp
;; https://elpa.gnu.org/packages/xclip.html
(use-package xclip :ensure nil
  :config
  (xclip-mode 1)
  )
#+end_src

This problem is somehow well-known [1] (that does not mean that I understand what's going on, just reporting that this happens, not only in xclip context)

Here, I am able to reproduce the hang with org-babel [1]:

#+begin_src bash
xclip -i /dev/null -selection clipboard
xclip -o -selection clipboard
#+end_src

it also hangs with the built-in shell-command elisp function calls:

(shell-command "echo 'clipboard content' | xclip -selection clipboard")
(shell-command "xclip -o -selection clipboard")


But I cannot reproduce the hang in a normal terminal (vterm, alacritty, even in a linux console; fails because cannot open display).


Inside the xclip.el, a process-call with the xclip program is invoked, then hangs, and then you need to press C-g several times, this happens with the following configurations:

    (setq xclip-method 'xclip)
    (setq xclip-method 'xsel)

Here, I suggest, to reduce UX-frustration throwing a timeout error; but I don't know how to do it. I just know the POSIX timeout command [2].

There is a workaround, unrelated to emacs: using the typical terminal clipboard paste command Ctrl+Shift+V, but I don't like to think if I am in a terminal emacs buffer or X11 emacs buffer, I want to flow and have something that works everywhere flawlessly. In fact, I also like to access the whole previous kill ring with M-y.


Then I found that the emacs xclip-method works fine for that corner case that I am describing, but then sometimes "looses the synchronization" (?) with the X11 clipboard and provides an old-wrong clipboard; so I end up copying and recopying from a random X11 app to emacs terminal without success (specially when doing it to the terminal window).

    (setq xclip-method 'emacs)


I also tried to hack on the xclip code, it is weird that when I override the function definition does not work, I think it would be nice to know the details/documentation on how to hack or change on this.

Anyway, trying stuff, when I replaced the paste content with hello world, it does not hang and it works, so it is clearly a problem when tries to get the xclip content from terminal and the last content was put in clipboard by emacs X11.

By the way, disabling xclip package, makes pasting the emacs X11 to emacs terminal work; but then, does not work with the rest of X11 clipboard apps.


Thanks for your attention,
pinmacs

[0] my compilation details:
  ./configure --with-native-compilation --with-native-compilation=aot --with-x-toolkit=lucid
  make -j4
  make bootstrap

[1] https://emacs.stackexchange.com/questions/39019/xclip-hangs-shell-command

[2] https://orgmode.org/worg/org-contrib/babel/

[3] https://pubs.opengroup.org/onlinepubs/9799919799/utilities/timeout.html




reply via email to

[Prev in Thread] Current Thread [Next in Thread]